View Issue Details

IDProjectCategoryView StatusLast Update
0038039PatchesLCLpublic2021-01-17 08:49
ReporterCyrax Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformLinux x86_64OSArch 
Product Version2.1 (SVN) 
Summary0038039: TApplication class in LCL uses old way to register ExitProc and the procedure which does clean up, do not restore old ExitProc.
DescriptionSee summary.

TApplication.Destroy is too late for restoring old ExitProc handler.

Attached patch will fix this bug.
TagsNo tags attached.
Fixed in Revisionr64110
LazTarget-
WidgetsetGTK 2
Attached Files

Relationships

related to 0038346 resolvedJuha Manninen Lazarus Finalization causes sigabrt and hangs app 

Activities

Cyrax

2020-11-05 01:03

reporter  

fix-exitproc-chain.diff (941 bytes)   
diff --git a/lcl/forms.pp b/lcl/forms.pp
index e065cef415..817ae9d17c 100644
--- a/lcl/forms.pp
+++ b/lcl/forms.pp
@@ -1397,7 +1397,6 @@ type
     FMouseControl: TControl;
     FNavigation: TApplicationNavigationOptions;
     FOldExceptProc: TExceptProc;
-    FOldExitProc: Pointer;
     FOnActionExecute: TActionEvent;
     FOnActionUpdate: TActionEvent;
     FOnActivate: TNotifyEvent;
diff --git a/lcl/include/application.inc b/lcl/include/application.inc
index 66279d346c..18ff38c855 100644
--- a/lcl/include/application.inc
+++ b/lcl/include/application.inc
@@ -119,8 +119,7 @@ begin
   inherited Create(AOwner);
   CaptureExceptions:=true;
 
-  FOldExitProc:=ExitProc;
-  ExitProc:=@BeforeFinalization;
+  AddExitProc(@BeforeFinalization);
   
   OnGetApplicationName := @GetApplicationName;
 end;
@@ -135,8 +134,6 @@ begin
 
   if Assigned(FOnDestroy) then FOnDestroy(Self);
 
-  ExitProc:=FOldExitProc;
-
   ProcessAsyncCallQueue;
 
fix-exitproc-chain.diff (941 bytes)   

jamie philbrook

2020-11-05 01:16

reporter   ~0126744

Unless I am blind, you specify the GTK2 as the widget but the changes you are making effects all which is the LCL.

Is the GTK2 getting effected by this ?

I know the report marks the LCL but you also only indicated one Widget instead of all of them..

Can you reproduce an error that is worthy of this change because this is the existing point of the app and I really can't see how and why this would make a difference ?

Cyrax

2020-11-05 01:22

reporter   ~0126745

Last edited: 2020-11-05 01:24

View 3 revisions

Please see this change at FPC trunk sources : https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/rtl/inc/thread.inc?r1=47311&r2=47310&pathrev=47311
If the ExitProc call chain isn't restored properly, there is a memory leak in FPC RTL.

EDIT : It is for all supported widgeset, I chose the GTK2 by habit.

Juha Manninen

2020-11-06 11:43

developer   ~0126769

Applied, thanks.

Juha Manninen

2021-01-15 20:02

developer   ~0128364

Cyrax, the related issue reports a problem in FPC trunk. Can you please look at it.

Juha Manninen

2021-01-17 08:49

developer   ~0128386

Resolving and closing again.

Issue History

Date Modified Username Field Change
2020-11-05 01:03 Cyrax New Issue
2020-11-05 01:03 Cyrax File Added: fix-exitproc-chain.diff
2020-11-05 01:16 jamie philbrook Note Added: 0126744
2020-11-05 01:22 Cyrax Note Added: 0126745
2020-11-05 01:23 Cyrax Note Edited: 0126745 View Revisions
2020-11-05 01:24 Cyrax Note Edited: 0126745 View Revisions
2020-11-06 11:08 Juha Manninen Assigned To => Juha Manninen
2020-11-06 11:08 Juha Manninen Status new => assigned
2020-11-06 11:43 Juha Manninen Status assigned => resolved
2020-11-06 11:43 Juha Manninen Resolution open => fixed
2020-11-06 11:43 Juha Manninen Fixed in Revision => r64110
2020-11-06 11:43 Juha Manninen LazTarget => -
2020-11-06 11:43 Juha Manninen Widgetset GTK 2 => GTK 2
2020-11-06 11:43 Juha Manninen Note Added: 0126769
2020-11-07 16:20 Cyrax Status resolved => closed
2021-01-11 18:16 Juha Manninen Relationship added related to 0038346
2021-01-15 20:02 Juha Manninen Status closed => assigned
2021-01-15 20:02 Juha Manninen Resolution fixed => open
2021-01-15 20:02 Juha Manninen Note Added: 0128364
2021-01-17 08:49 Juha Manninen Status assigned => resolved
2021-01-17 08:49 Juha Manninen Resolution open => fixed
2021-01-17 08:49 Juha Manninen Widgetset GTK 2 => GTK 2
2021-01-17 08:49 Juha Manninen Note Added: 0128386
2021-01-17 08:49 Juha Manninen Status resolved => closed