[fpc-pascal] Dynlibs.LoadLibrary on 64bit Debian (Ubuntu)

Jonas Maebe jonas.maebe at elis.ugent.be
Tue Dec 23 19:03:00 CET 2008


On 23 Dec 2008, at 14:54, Andrew Brunner wrote:

> 'm running into another issue where I create all classes from scratch
> to avoid using Classes unit inside library and now my library won't
> load.  The only FPC related unit I use is SysUtils.

I cannot reproduce this crash following http://bugs.freepascal.org/view.php?id=12814

I completed the main program (please always submit fully compilable  
code, not just snippets) as follows:

{$mode delphi}
uses
   dynlibs;

procedure Test();
var
   FLib : TLibHandle;
begin
   FLib:=Dynlibs.LoadLibrary('./libMatrixMemoryManager.so');
   DynLibs.UnloadLibrary(FLib); // WILL CRASH HERE.
end;

begin
   test;
end.


Note that I replaced "MatrixMemoryManager.so" with  
"libMatrixMemoryManager.so". I get a crash if loadlibrary fails and  
returned 0. You should check for this condition in your code. Other  
than that, it works fine:

~/fpc/test/tw12814$ ppcxf1 -l MatrixMemoryManager.pp
Free Pascal Compiler version 2.2.3 [2008/12/17] for x86_64
Copyright (c) 1993-2008 by Florian Klaempfl
Target OS: Linux for x86-64
Compiling MatrixMemoryManager.pp
Linking libMatrixMemoryManager.so
18 lines compiled, 0.4 sec
~/fpc/test/tw12814$ ppcxf1 -l tt.pp
Free Pascal Compiler version 2.2.3 [2008/12/17] for x86_64
Copyright (c) 1993-2008 by Florian Klaempfl
Target OS: Linux for x86-64
Compiling tt.pp
Linking tt
15 lines compiled, 0.2 sec
~/fpc/test/tw12814$ ./tt
~/fpc/test/tw12814$ echo $?
0
~/fpc/test/tw12814$ cat MatrixMemoryManager.pp
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.

This is on Scientific Linux 5.2 (free distro based on Red Hat  
Enterprise Linux 5.2). Are you sure that you are using 2.2.3 and not  
2.3.1?


Jonas



More information about the fpc-pascal mailing list