View Issue Details

IDProjectCategoryView StatusLast Update
0035862FPCRTLpublic2019-07-23 18:34
ReporterAnton KavalenkaAssigned ToSven Barth 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version3.3.1Product Build 
Target VersionFixed in Version3.3.1 
Summary0035862: sysutils: Terminate proc linked list is never freed either never invoked
DescriptionCompile attached example in -Mdelphi

By design terminate proc can be added in any unit and the executed at application termination time.
Not a problem that "CallTerminateProcs" never called - it can be the consequences of LCL structure,
but the linked list with these pointer has to be freed.
I.e. not exists complementary deallocator for the list.

Proposed solution - delete allocated objects in finalization section of every sysutils.pp implementation.
TagsNo tags attached.
Fixed in Revision42457,42461
FPCOldBugId
FPCTarget-
Attached Files
  • tp.pas (251 bytes)
    program tp;
    uses sysutils;
    
    function do_term:boolean;
    begin
      writeln('In terminate proc');
      Result:=true;
    end;
    
    begin
      writeln('Adding terminate proc');
      AddTerminateproc(@do_term);
      writeln('terminating');
      CallterminateProcs;
    end.
    tp.pas (251 bytes)

Activities

Anton Kavalenka

2019-07-19 15:15

reporter  

tp.pas (251 bytes)
program tp;
uses sysutils;

function do_term:boolean;
begin
  writeln('In terminate proc');
  Result:=true;
end;

begin
  writeln('Adding terminate proc');
  AddTerminateproc(@do_term);
  writeln('terminating');
  CallterminateProcs;
end.
tp.pas (251 bytes)

Anton Kavalenka

2019-07-19 15:16

reporter   ~0117315

Last edited: 2019-07-19 15:40

View 3 revisions

related to 0035013 and causes a memory leak

complie the sample with -gh and memory leak would be twice the size of pointer = recors size
TPRecord = Record
    Func : TTerminateProc;
    NextFunc : PPRecord;
  end;

Sven Barth

2019-07-19 17:56

manager   ~0117321

Please test and close if okay.

Anton Kavalenka

2019-07-19 18:06

reporter   ~0117323

Is not the DoneExceptions has to be the latest one, because InitExceptions is the first-one?
When the linked list is corrupted for some reason - EaccessViolation would be raised.

Sven Barth

2019-07-20 10:43

manager   ~0117326

You're right, I hadn't thought about that. I changed the order in r42461.

Please test and close if okay.

Issue History

Date Modified Username Field Change
2019-07-19 15:15 Anton Kavalenka New Issue
2019-07-19 15:15 Anton Kavalenka File Added: tp.pas
2019-07-19 15:16 Anton Kavalenka Note Added: 0117315
2019-07-19 15:19 Anton Kavalenka Note Edited: 0117315 View Revisions
2019-07-19 15:40 Anton Kavalenka Note Edited: 0117315 View Revisions
2019-07-19 17:56 Sven Barth Assigned To => Sven Barth
2019-07-19 17:56 Sven Barth Status new => resolved
2019-07-19 17:56 Sven Barth Resolution open => fixed
2019-07-19 17:56 Sven Barth Fixed in Version => 3.3.1
2019-07-19 17:56 Sven Barth Fixed in Revision => 42457
2019-07-19 17:56 Sven Barth FPCTarget => -
2019-07-19 17:56 Sven Barth Note Added: 0117321
2019-07-19 18:06 Anton Kavalenka Status resolved => feedback
2019-07-19 18:06 Anton Kavalenka Resolution fixed => reopened
2019-07-19 18:06 Anton Kavalenka Note Added: 0117323
2019-07-20 10:43 Sven Barth Status feedback => resolved
2019-07-20 10:43 Sven Barth Fixed in Revision 42457 => 42457,42461
2019-07-20 10:43 Sven Barth Note Added: 0117326
2019-07-20 10:43 Sven Barth Resolution reopened => fixed
2019-07-20 10:43 Sven Barth Description Updated View Revisions
2019-07-23 18:34 Anton Kavalenka Status resolved => closed