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

Sven Barth pascaldragon at googlemail.com
Tue Sep 30 15:13:12 CEST 2014

Am 30.09.2014 15:07 schrieb "Mark Morgan Lloyd" <
markMLl.fpc-pascal at telemetry.co.uk>:
>> As far as I know, the initialization entry point is called automatically.
>> But the compiler experts should confirm this. IIRC the behaviour changed
as the support for libraries improved;
> ..(pending comment from compiler experts) there are completely separate
trees of units in the main program and each dynamically-loaded library. The
OS calls the initialisation block(s) for each library, and then finally
calls the initialisation block for the main program. So in the context of
one particular library, code in the main library initialisation block
should have a similar standing to that in the main program initialisation
block: everything else in that context (i.e. in the library or in the main
program) has been initialised before it is called, and when it exits it
goes back to the OS (possibly via finalisation blocks).

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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20140930/ba65c056/attachment.html>

More information about the fpc-pascal mailing list