[fpc-pascal] Reproducible code: DLL calling Firebird crashes

Sven Barth pascaldragon at googlemail.com
Tue Sep 30 21:38:09 CEST 2014


On 30.09.2014 20:17, Marco van de Voort wrote:
> In our previous episode, Sven Barth said:
>> It is indeed true that all units are initialized once the main code block
>> of the library is called, but you are still inside the library
>> initialization initiated by the OS and thus you are subject to its
>> restrictions which in the case of Windows includes not to load any
>> libraries there.
>
> So the obvious question might be if the unit initialization really  belongs
> into the library initialization like that.

The only other alternative would be to add the RTL initialization code 
to each exported function. I don't consider this a viable alternative.

Note: Dynamic packages won't have this problem, because:
- for packages linked at compile time the initialization is run as part 
of the program initialization AFTER the OS has initialized the library 
(which doesn't do much in case of a package)
- for packages loaded at runtime it's done as part of the LoadPackage call
That's however only possible, because dynamic packages are very 
different from simple libraries (and stuffed with compiler magic).

Regards,
Sven



More information about the fpc-pascal mailing list