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]
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to