[fpc-pascal] Reproducible code: DLL calling Firebird crashes
Mark Morgan Lloyd
markMLl.fpc-pascal at telemetry.co.uk
Mon Sep 29 11:19:08 CEST 2014
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:
> https://bitbucket.org/reiniero/fpc_laz_patch_playground/downloads/dllcrash.zip
>
> 1. Please update your Firebird server details in dbinterface.pas to your
> situation (hostname etc)
> 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
writeln('Starting demo');
writeln('TheAnswer is:');
InitialiseBackend;
try
writeln(TheAnswer)
finally
FinaliseBackend
end;
writeln('Ending demo');
--
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