DynLibs.UnloadLibrary Consistently Fails if Library has classes in uses statement
Original Reporter info from Mantis: aurawin
-
Reporter name: Andrew Brunner
Original Reporter info from Mantis: aurawin
- Reporter name: Andrew Brunner
Description:
FPC Build : Latest and greatest from SVN as per a few days ago.
Lazarus Build : Latest and greatest from SVN as per a few days ago.
Target Build x64 Ubuntu
The UnloadLibrary method always fails when you build the library with the "classes" unit included in the uses of the library.
Additional information:
Running under GDB I get the following info...
This GDB was configured as "x86_64-linux-gnu"...
(gdb) run
Starting program: /mnt/Raid/Developer/Source/Lazarus/Test/TestApplication
[Thread debugging using libthread_db enabled]
[New Thread 0x7f9e79102770 (LWP 7388)]
[WARNING] Out of OEM specific VK codes, changing to unassigned
[WARNING] Out of unassigned VK codes, assigning $FF
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7f9e79102770 (LWP 7388)]
0x00007f9e71a38d68 in fpc_finalize ()
from /home/atbrunner/Source/Lazarus/Libraries/MatrixMemory/MatrixMemoryManager.so
(gdb)
#1 0x00007f9e719f6170 in ?? ()
#2 0x00007f9e71c40060 in _$CLASSES$_Ld233 ()
from /home/atbrunner/Source/Lazarus/Libraries/MatrixMemory/MatrixMemoryManager.so
#3 0x00007fff8092e038 in ?? ()
#4 0x00007f9e719f6170 in ?? ()
#5 0x00007f9e71c40060 in _$CLASSES$_Ld233 ()
from /home/atbrunner/Source/Lazarus/Libraries/MatrixMemory/MatrixMemoryManager.so
#6 0x00007fff8092e050 in ?? ()
#7 0x00007f9e719f6170 in ?? ()
#8 0x00007f9e71c40060 in _$CLASSES$_Ld233 ()
from /home/atbrunner/Source/Lazarus/Libraries/MatrixMemory/MatrixMemoryManager.so
#9 0x00007fff8092e068 in ?? ()
#10 0x00007f9e719f6170 in ?? ()
#11 0x00007f9e71c40060 in _$CLASSES$_Ld233 ()
from /home/atbrunner/Source/Lazarus/Libraries/MatrixMemory/MatrixMemoryManager.so
#12 0x00007fff8092e080 in ?? ()
#13 0x00007f9e719f6170 in ?? ()
#14 0x00007f9e71c40060 in _$CLASSES$_Ld233 ()
from /home/atbrunner/Source/Lazarus/Libraries/MatrixMemory/MatrixMemoryManager.so
#15 0x00007fff8092e098 in ?? ()
#16 0x00007f9e719f6170 in ?? ()
#17 0x00007f9e71c40060 in _$CLASSES$_Ld233 ()
from /home/atbrunner/Source/Lazarus/Libraries/MatrixMemory/MatrixMemoryManager.so
#18 0x00007fff8092e0b0 in ?? ()
#19 0x00007f9e719f6170 in ?? ()
#20 0x00007f9e71c40060 in _$CLASSES$_Ld233 ()
from /home/atbrunner/Source/Lazarus/Libraries/MatrixMemory/MatrixMemoryManager.so
#21 0x00007fff8092e0c8 in ?? ()
#22 0x00007f9e719f6170 in ?? ()
#23 0x00007f9e71c40060 in _$CLASSES$_Ld233 ()
from /home/atbrunner/Source/Lazarus/Libraries/MatrixMemory/MatrixMemoryManager.so
#24 0x00007fff8092e0e0 in ?? ()
#25 0x00007f9e719f6170 in ?? ()
#26 0x00007f9e71c40060 in _$CLASSES$_Ld233 ()
It appears that something is wrong with the classes unit or something.
Keep in mind, the compiled library is nothing more than 2 functions
declared as exported booleans that don't have any parameters.
----- Sample Code ----
library MatrixMemoryManager;
{$mode objfpc}{$H+}
uses cMem,SysUtils,Classes;
var
List:TList;
function Startup:boolean; stdcall; export;
begin
List:=TList.Create;
Result:=True;
end;
function Shutdown:boolean; stdcall; export;
begin
FreeAndNil(List);
Result:=True;
end;
exports Startup, Shutdown;
begin
end.
Then, you need a host application which loads the library...
procedure Test();
var
FLib : TLibHandle;
begin
FLib:=Dynlibs.LoadLibrary('/completepath/MatrixMemoryManager.so');
DynLibs.UnloadLibrary(FLib); // WILL CRASH HERE.
end;
Mantis conversion info:
- Mantis ID: 12814
- Version: 2.3.1