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

Lukas Zeller luz_info at synthesis.ch
Fri Sep 18 10:14:56 CEST 2009


Hi Jonas,

Thanks for testing that and the explanation of Apple linker issues.  
Makes sense now - it's no problem for us to build on 10.5 for now  
until a future version of FPC can work around the problem or the Apple  
linker gets fixed. It looks like the former is the case :-)

The only thing not explained yet are the crashes we had on 10.5 (built  
there, run there) with the real program, which *looked* like it was  
the same problem (crash without the Write(), no crash with Write() in  
place). But given the facts that the sample program is working  
correctly on 10.5 it might have been something else. I'll have that  
checked again to make sure, and will report if I can reproduce it on  
10.5 somehow.

Thanks again for your help!

Best Regards,

Lukas


On Sep 17, 2009, at 19:59 , Jonas Maebe wrote:

>
> 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
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel




More information about the fpc-devel mailing list