View Issue Details

IDProjectCategoryView StatusLast Update
0019781FPCRTLpublic2011-10-17 11:52
ReporterWerner Bochtler Assigned ToThomas Schatzl  
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Platform x86_64OSLinux 
Product Version2.4.4 
Target Version2.7.1 
Summary0019781: finalization section in x86_64 shared libraries is not executed
DescriptionIn 64 bit shared libraries (LINUX) the finalization section is not executed.

The attached demo works as expected using FPC 2.4.4 in a 32-bit environment i.e. the application writes the following 3 lines to STDOUT:

"initialization done"
"Main"
"finalization done"

Using FPC 2.4.4 (64 bit) the last line is missing.
Steps To ReproduceCompile library in Library folder
Install library
Compile application in Application folder
Execute application
TagsNo tags attached.
Fixed in Revision19036
FPCOldBugId
FPCTarget
Attached Files

Activities

2011-07-21 10:57

 

demo.zip (66,643 bytes)

Jonas Maebe

2011-07-21 13:07

manager   ~0050080

Last edited: 2011-07-21 13:07

On Linux, shared library finalization is currently indeed only implemented on i386. Thomas is working on implementing it for other architectures.

Thomas Schatzl

2011-09-09 09:54

developer   ~0051633

Should be fixed in trunk revision r19036 (for ppc,ppc64,arm,x86_64).

Werner Bochtler

2011-09-12 10:43

reporter   ~0051739

I have tried the uploaded demo application/library with the latest 2.7.1 (downloaded a few minutes ago). Unfortunately the problem still occurs. The output line "finalization done" is still missing i.e. the finalization code of the library is not executed.

Thomas Schatzl

2011-09-21 21:56

developer   ~0052088

Two notes:

 - the "uses systemlog" trick in the example is not needed anymore. The revision mentioned earlier also fixes that problem.

 - when using -dPIC to compile your library (like in the provide fpc.cfg) make sure that the RTL has also been compiled with -dPIC. Using a non-PIC RTL with a PIC shared library does not work.

A hint whether you have a correct setup may be the file size of the resulting libMyTest.so: it should be around 180k (everything no PIC) or 190k (all PIC). The non-working libMyTest.so (non-PIC RTL with PICed demo .so) has only 36k.

Please retest.

Jonas Maebe

2011-10-17 11:52

manager   ~0053089

No feedback, and it works fine here regardless of whether the program is compiler with -Cg or not:

$ ppcx1 MyTestDemo.dpr -Fl../binFree Pascal Compiler version 2.7.1 [2011/10/17] for x86_64
Copyright (c) 1993-2011 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling MyTestDemo.dpr
Linking MyTestDemo
8 lines compiled, 0.9 sec
jmaebe@boskeun:~/fpc/test/tw19781/Application$ LD_LIBRARY_PATH=../bin ./MyTestDemo
initialization done
Main
finalization done

$ ppcx1 MyTestDemo.dpr -Cg -Fl../bin
Free Pascal Compiler version 2.7.1 [2011/10/17] for x86_64
Copyright (c) 1993-2011 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling MyTestDemo.dpr
Linking MyTestDemo
8 lines compiled, 0.4 sec
$ LD_LIBRARY_PATH=../bin ./MyTestDemo
initialization done
Main
finalization done

Issue History

Date Modified Username Field Change
2011-07-21 10:57 Werner Bochtler New Issue
2011-07-21 10:57 Werner Bochtler File Added: demo.zip
2011-07-21 13:07 Jonas Maebe Note Added: 0050080
2011-07-21 13:07 Jonas Maebe Status new => assigned
2011-07-21 13:07 Jonas Maebe Assigned To => Thomas Schatzl
2011-07-21 13:07 Jonas Maebe Note Edited: 0050080
2011-09-09 09:54 Thomas Schatzl Note Added: 0051633
2011-09-09 10:13 Thomas Schatzl Status assigned => feedback
2011-09-09 10:13 Thomas Schatzl Target Version => 2.7.1
2011-09-12 10:43 Werner Bochtler Note Added: 0051739
2011-09-21 21:56 Thomas Schatzl Note Added: 0052088
2011-10-17 11:52 Jonas Maebe Fixed in Revision => 19036
2011-10-17 11:52 Jonas Maebe Status feedback => resolved
2011-10-17 11:52 Jonas Maebe Resolution open => fixed
2011-10-17 11:52 Jonas Maebe Note Added: 0053089