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

Mark Morgan Lloyd markMLl.fpc-pascal at telemetry.co.uk
Mon Sep 29 17:41:34 CEST 2014


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 order plays a part?!?
>>>
>>> How should I fix this?
>> 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
> As the demo indicates, that does work (undefine CRASH).
> 
> 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.

No, your example shows an implicit initialisation when the backend is 
accessed. I was suggesting an explicit initialisation, so that the app 
can if necessary tell the backend what localisation conventions to use. 
OK, it's an excuse but it gets you out of the current hole.

In the longer term I think this probably merits a bug report, so that 
library initialisation etc. can be explored. This does look like a 
sequencing issue rather than something being on the wrong heap.

-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]



More information about the fpc-pascal mailing list