View Issue Details

IDProjectCategoryView StatusLast Update
0023026LazarusPrinterpublic2014-07-15 17:58
ReporterLuiz AmericoAssigned ToJesus Reyes 
PrioritynormalSeveritycrashReproducibilityalways
Status closedResolutionfixed 
Product Version1.0.8Product Build 
Target Version1.2.0Fixed in Version1.3 (SVN) 
Summary0023026: Program crashes if printer units are added to project under windows 64bit
DescriptionTo get the crash:

1) Create an empty project
2) Add printer4lazarus requirement
3) Add Printers unit to uses
4) Run the program
5) Close the program -> BUM!

The crash occurs in a call to CreateDC in a cascade started due to a call to DoResetPrintersList in destructor of TWinPrinter

Removing the call to DoResetPrintersList fixes the issue

Using Lazarus 1.0 r38415 FPC 2.6.0 x86_64-win64-win32/win64 under windows 7 64bit

Tested again with Lazarus 64bit 1.0.8 + fpc 2.6.2 (official installer) under windows 7
TagsNo tags attached.
Fixed in Revision43024
LazTarget1.2
WidgetsetWin32/Win64
Attached Files

Relationships

related to 0012974 new FPC FPC can't catch windows exceptions (av's) in a try/except in a dll call 
has duplicate 0025310 closedJesus Reyes Lazarus Error in file winprinters.inc, compiled on Win 64 bits 
related to 0026489 closedJesus Reyes Lazarus Out of memory 

Activities

Luiz Americo

2012-09-30 02:37

developer   ~0062756

I noticed that not only in destruction it crashes.

If i call f PrintDialog.Execute it will crash in the same place:
 First call to CreateDC in TWinPrinter.SetDC

Luiz Americo

2012-09-30 06:34

developer   ~0062759

More info:
 - It does not matter if printer is on or off
 - Exactly the same program in the same computer does not crashes if is compiled with a 32bit compiler (fpc 260). The CreateDC call runs fine
 - StackTrace:

TApplication.HandleException CreateDC Exception:"Control-C hit" (Error:"A operaþ
Òo foi concluÝda com Ûxito.
", DC=0 Driver="HP Officejet 4500 G510a-f" Device="HP Officejet 4500 G510a-f" Po
rt="USB001")
  Stack trace:
  $0000000000638E8E TWINPRINTER__SETDC, line 159 of ./win32/winprinters.inc
  $00000000006389CE TWINPRINTER__PRINTERSELECTED, line 84 of ./win32/winprinte
rs.inc
  $000000000062EB62 TPRINTER__SETPRINTER, line 475 of printers.pas
  $000000000062F265 TPRINTER__SETPRINTERINDEX, line 686 of printers.pas
  $000000000062F31E TPRINTER__SELECTCURRENTPRINTERORDEFAULT, line 705 of print
ers.pas
  $000000000062F01A TPRINTER__GETPRINTERS, line 632 of printers.pas
  $0000000000637BBA TPRINTDIALOG__EXECUTE, line 201 of ./win32/winprndialogs.i
nc
  $00000000005DE46F TWINDOWSXPFORM__TOOLBUTTON9CLICK, line 268 of WindowsXPSty
leDemo.pas
  $000000000056349B TCONTROL__CLICK, line 2742 of ./include/control.inc
  $0000000000530925 TTOOLBUTTON__CLICK, line 772 of ./include/toolbutton.inc
  $000000000052EB9D TTOOLBUTTON__MOUSEUP, line 136 of ./include/toolbutton.inc

  $0000000000562607 TCONTROL__DOMOUSEUP, line 2192 of ./include/control.inc
  $00000000005631C0 TCONTROL__WMLBUTTONUP, line 2640 of ./include/control.inc
  $000000000040CCFE
  $0000000000560F6D TCONTROL__PERFORM, line 1467 of ./include/control.inc
  $00000000005512A1 TWINCONTROL__ISCONTROLMOUSEMSG, line 4678 of ./include/win
control.inc
  $0000000000552EA0 TWINCONTROL__WNDPROC, line 5287 of ./include/wincontrol.in
c
WARNING: TLCLComponent.Destroy with LCLRefCount>0. Hint: Maybe the component is
processing an event?

José Mejuto

2012-10-09 20:29

reporter   ~0063032

Run the compiled program without gdb.

The same happends to me with gdb in 32 bits and finally it was related to a faulty printer driver that raises an exception that is being catched by gdb :-?
Just changed my default printer to other one and no problem, until I try to select the faulty one.
Without gdb no problem at all.

Luiz Americo

2013-04-11 17:43

developer   ~0066926

I get the error even if not running under GDB

Tested with Lazarus 1.0.8 + fpc 2.6.2 (official installer) under windows 7

José Mejuto

2013-04-11 19:55

reporter   ~0066929

Try using 2.7.1 because a win64 exception in the driver could be badly handled in 2.6.2 because it does not shave SEH.

Luiz Americo

2013-04-13 15:04

developer   ~0066945

@mejuto: good hint. Probably a fpc bug. Unfortunately i can't test 2.7.1 now. I'll do as soon as possible

Jesus Reyes

2013-09-29 07:03

developer   ~0070437

Ok, r43024 fix specifically the bug as described in "description". The bug reported in note 62756 won't be fixed by this patch because as José Mejuto noted, this seems to be a problem in FPC about SEH exception handling, which is fixed in FPC 2.7.1.

As as side note, comments in bug 0012974 talk about this same problem, and I tested the solution given by Bernd Engelhardt in note 40688 and it works fine when using FPC 2.6.2, no further tests were made except by recompiling Lazarus and the problem described in this report. So use at on your own risk ;)

Issue History

Date Modified Username Field Change
2012-09-30 02:32 Luiz Americo New Issue
2012-09-30 02:32 Luiz Americo LazTarget => -
2012-09-30 02:32 Luiz Americo Widgetset => Win32/Win64
2012-09-30 02:33 Luiz Americo LazTarget - => 1.0.2
2012-09-30 02:37 Luiz Americo Note Added: 0062756
2012-09-30 06:34 Luiz Americo Note Added: 0062759
2012-10-09 13:42 Martin Friebe LazTarget 1.0.2 => 1.0.4
2012-10-09 13:46 Martin Friebe Target Version 1.0.2 => 1.0.4
2012-10-09 20:29 José Mejuto Note Added: 0063032
2013-04-11 17:43 Luiz Americo Note Added: 0066926
2013-04-11 17:44 Luiz Americo LazTarget 1.0.4 => 1.0.10
2013-04-11 17:44 Luiz Americo Product Version => 1.0.8
2013-04-11 17:44 Luiz Americo Target Version 1.0.4 => 1.0.10
2013-04-11 17:45 Luiz Americo Description Updated View Revisions
2013-04-11 18:30 Jesus Reyes Assigned To => Jesus Reyes
2013-04-11 18:30 Jesus Reyes Status new => assigned
2013-04-11 19:55 José Mejuto Note Added: 0066929
2013-04-13 15:04 Luiz Americo Note Added: 0066945
2013-09-14 00:41 Martin Friebe LazTarget 1.0.10 => 1.2
2013-09-14 00:42 Martin Friebe Target Version 1.0.10 => 1.2.0
2013-09-29 07:03 Jesus Reyes Fixed in Revision => 43024
2013-09-29 07:03 Jesus Reyes Note Added: 0070437
2013-09-29 07:03 Jesus Reyes Status assigned => resolved
2013-09-29 07:03 Jesus Reyes Fixed in Version => 1.3 (SVN)
2013-09-29 07:03 Jesus Reyes Resolution open => fixed
2013-09-29 07:04 Jesus Reyes Relationship added related to 0012974
2013-09-29 13:11 Luiz Americo Status resolved => closed
2013-11-12 22:38 Jesus Reyes Relationship added has duplicate 0025310
2014-07-15 17:58 Jesus Reyes Relationship added related to 0026489