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

2014-10-02 Thread Mark Morgan Lloyd
Reinier Olislagers wrote: On 30/09/2014 22:05, Mark Morgan Lloyd wrote: 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 Reinier: did you get as far as looking in Dynlibs for an error message immediately

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

2014-10-02 Thread Reinier Olislagers
On 02/10/2014 12:19, Mark Morgan Lloyd wrote: Reinier Olislagers wrote: On 30/09/2014 22:05, Mark Morgan Lloyd wrote: 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 Reinier: did you get as far as looking

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

2014-10-02 Thread Michael Van Canneyt
On Thu, 2 Oct 2014, Reinier Olislagers wrote: On 02/10/2014 12:19, Mark Morgan Lloyd wrote: Reinier Olislagers wrote: On 30/09/2014 22:05, Mark Morgan Lloyd wrote: Marco van de Voort wrote: In our previous episode, Sven Barth said: It is indeed true that all units are initialized once

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

2014-10-01 Thread Marco van de Voort
In our previous episode, Sven Barth said: 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

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

2014-09-30 Thread Reinier Olislagers
On 29/09/2014 19:30, Reinier Olislagers wrote: Re bug report: agreed. I'll raise it. http://bugs.freepascal.org/view.php?id=26801 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org

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

2014-09-30 Thread Mark Morgan Lloyd
Reinier Olislagers wrote: On 29/09/2014 19:30, Reinier Olislagers wrote: Re bug report: agreed. I'll raise it. Jonas has already closed it, noting http://msdn.microsoft.com/en-us/library/windows/desktop/ms682583%28v=vs.85%29.aspx *** The entry-point function should perform only simple

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

2014-09-30 Thread Michael Van Canneyt
On Tue, 30 Sep 2014, Mark Morgan Lloyd wrote: Reinier Olislagers wrote: On 29/09/2014 19:30, Reinier Olislagers wrote: Re bug report: agreed. I'll raise it. Jonas has already closed it, noting http://msdn.microsoft.com/en-us/library/windows/desktop/ms682583%28v=vs.85%29.aspx *** The

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

2014-09-30 Thread Mark Morgan Lloyd
Michael Van Canneyt wrote: On Tue, 30 Sep 2014, Mark Morgan Lloyd wrote: Reinier Olislagers wrote: On 29/09/2014 19:30, Reinier Olislagers wrote: Re bug report: agreed. I'll raise it. Jonas has already closed it, noting

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

2014-09-30 Thread Michael Van Canneyt
On Tue, 30 Sep 2014, Mark Morgan Lloyd wrote: Michael Van Canneyt wrote: On Tue, 30 Sep 2014, Mark Morgan Lloyd wrote: Reinier Olislagers wrote: On 29/09/2014 19:30, Reinier Olislagers wrote: Re bug report: agreed. I'll raise it. Jonas has already closed it, noting

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

2014-09-30 Thread Mark Morgan Lloyd
Michael Van Canneyt wrote: However I'd precede that by a thought based on what Jose said. In your example, you're opening the database in the initialisation block of businesslayer.pas, which is invoked at an arbitrary position in the init sequence of the DLL/so. If that operation were moved

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

2014-09-30 Thread Sven Barth
Am 30.09.2014 15:07 schrieb Mark Morgan Lloyd markmll.fpc-pas...@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

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

2014-09-30 Thread Marco van de Voort
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

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

2014-09-30 Thread Sven Barth
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

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

2014-09-30 Thread Mark Morgan Lloyd
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

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

2014-09-30 Thread Mark Morgan Lloyd
Sven Barth wrote: The only other alternative would be to add the RTL initialization code to each exported function. I don't consider this a viable alternative. Which is more or less what Reinier's working code did. I'd hate that to be an implicit default. Note: Dynamic packages won't have

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

2014-09-30 Thread Reinier Olislagers
On 30/09/2014 22:05, Mark Morgan Lloyd wrote: 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 Reinier: did you get as far as looking in Dynlibs for an error message immediately after trying to connect to

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

2014-09-29 Thread Mark Morgan Lloyd
Reinier Olislagers wrote: Apparently my crashes in a dll that use Firebird have to do with initialization sections in my business layer creating a single instance of my db layer. Distilled reproducible code that demonstrates problem:

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

2014-09-29 Thread Reinier Olislagers
On 29/09/2014 11:19, Mark Morgan Lloyd wrote: Reinier Olislagers wrote: 2. In businesslayer.pas, $define CRASH to see the problem. The code in question is: initialization DBLayer:=TDBInterface.Create; finalization DBLayer.Free; ... so probably initialization order plays a part?!?

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

2014-09-29 Thread Reinier Olislagers
On 29/09/2014 11:19, Mark Morgan Lloyd wrote: Reinier Olislagers wrote: What happens if you move the responsibility for initialising and closing the database connection to the app-level code? In other words, the app does something like Ok, after eliminating some PEBKAC, my real dll works

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

2014-09-29 Thread José Mejuto
El 29/09/2014 a las #4, Reinier Olislagers escribió: What I would like to know what is the cause of this problem - dlls being loaded before some kind - what kind? - of initialization is complete? Anyway, I'll keep digging; probably first looking at geting postgresql support in anyway.

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

2014-09-29 Thread Reinier Olislagers
On 29/09/2014 16:51, José Mejuto wrote: El 29/09/2014 a las #4, Reinier Olislagers escribió: You must not initialize dbengine in the Initialization section and must not finalize it in that place (maybe only as last chance) because initialization order and finalization order is undefined by fpc

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

2014-09-29 Thread Mark Morgan Lloyd
Reinier Olislagers wrote: On 29/09/2014 11:19, Mark Morgan Lloyd wrote: Reinier Olislagers wrote: 2. In businesslayer.pas, $define CRASH to see the problem. The code in question is: initialization DBLayer:=TDBInterface.Create; finalization DBLayer.Free; ... so probably initialization

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

2014-09-29 Thread Reinier Olislagers
On 29/09/2014 17:41, Mark Morgan Lloyd wrote: Reinier Olislagers wrote: On 29/09/2014 11:19, Mark Morgan Lloyd wrote: Reinier Olislagers wrote: 2. In businesslayer.pas, $define CRASH to see the problem. The code in question is: initialization DBLayer:=TDBInterface.Create; finalization

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

2014-09-29 Thread Mark Morgan Lloyd
Reinier Olislagers wrote: On 29/09/2014 17:41, Mark Morgan Lloyd wrote: Reinier Olislagers wrote: On 29/09/2014 11:19, Mark Morgan Lloyd wrote: Reinier Olislagers wrote: 2. In businesslayer.pas, $define CRASH to see the problem. The code in question is: initialization