[fpc-devel] FPC shared lib called from C shared lib called from C main program crashes

Jonas Maebe jonas.maebe at elis.ugent.be
Thu Sep 17 19:59:45 CEST 2009


On 17 Sep 2009, at 17:52, Lukas Zeller wrote:

> In the meantime I tested the supersimple test program that reliable  
> crashes on 10.6 also on a 10.5 installation.
> Now here it behaves correctly (?!)
>
> HOWEVER, with the original, big program the problem also shows on  
> 10.5.
> As I discovered another side effect (garbled function result, see  
> readme.txt below) on 10.6, I assume there IS something within FPC  
> that can cause internal memory damage - and it's a matter of luck if  
> that leads to a full crash or not.
>
> As the examples are so small, I post them here for further discussion:

I assume that you tested under 10.6, and the strange results there are  
presumably due to the broken init code reordering by the linker. When  
I use a compiler that passes -no_order_inits to the linker (note that  
you cannot do this with 2.2.4 using -k-no_order_inits for the reasons  
explained in the bug report I referred to earlier), it works fine for  
me:

* with the writeln in the library init code:
$ ./hello
Comment out this, and the writeln above in function ua will crash
hello world
using standard output from pascal lib
universal answer = 42

* without the writeln in the init code:
$ ./hello
hello world
using standard output from pascal lib
universal answer = 42

Note that the problem is the linking under 10.6, not the running. So a  
library compiled/linked under 10.6 will also fail on 10.5 (even if  
compiled with -k-mmacosx_version_min=10.5 and against the 10.5 SDK),  
while a library compiled/linked under 10.5 will actually work fine  
under 10.6.


Jonas



More information about the fpc-devel mailing list