Cannot quit app cleanly after first use of unidac - updated
Posted: Wed 20 May 2015 15:15
I have a strange Delphi problem in a quite huge application I migrated from FIB to Unidac:
As soon as the connection to firebird is used once , I cannto quit the application by application.terminate anymore. Symptom is: My application seems to get into an infinitive loop and then crashes with an access violation. Currently I used a workaround by terminating "the hard way", but this does not allow using fastMM features for debugging memory leaks.
I traced down the problem to appear in system.pas:finalizeUnits. It is kind of strange that finalizeUnits calls itself in the except path:
I also traced it down to only appear if a connection to FIrebird was made with unidac. If I quit the application right before db.connected:=true; (db is a TUniConnection), it works fine, immediately after this command quitting without the exception is no longer possible. I tried to disconnect again and changing several options of unidac to no avail.
Even if I use a seperate TUniConnection DBTest in the datamodule without any events used and no data components connected to it, this error is reproducable:
I suspect that unloading firebird.dll is the problem.
Update: Following a suggestion from the Stackoverflow forum I traced the count index in system.pas to find the unit which is causing the problem by stepping into. Unfortunately the finalization routine causing the problem points into nirvana and not into any unit.
Environment: Delphi XE6 Enterprise, Firebird 2.5.4 embedded client connecting to Firebird 1.56 oder 2.54.
Any help would be very appreciated as I urgently have to track down a memory leak and cannot use fastMM wit this error;-(
Best regards Michael
As soon as the connection to firebird is used once , I cannto quit the application by application.terminate anymore. Symptom is: My application seems to get into an infinitive loop and then crashes with an access violation. Currently I used a workaround by terminating "the hard way", but this does not allow using fastMM features for debugging memory leaks.
I traced down the problem to appear in system.pas:finalizeUnits. It is kind of strange that finalizeUnits calls itself in the except path:
Code: Select all
procedure FinalizeUnits;
...
try
while Count > 0 do
begin
Dec(Count);
InitContext.InitCount := Count;
P := Table^[Count].FInit;
if Assigned(P) and Assigned(Pointer(P^)) then
begin
{$IF defined(MSWINDOWS)}
TProc(P)();
{$ELSEIF (defined(POSIX) and defined(CPUX86))}
CallProc(P, InitContext.Module^.GOT);
{$ELSE}
TProc(P)();
{$ENDIF}
end;
end;
except
FinalizeUnits; { try to finalize the others }
raise;
end;
...
Even if I use a seperate TUniConnection DBTest in the datamodule without any events used and no data components connected to it, this error is reproducable:
Code: Select all
// if I quit here, everything is fine
dbtest.SpecificOptions.values['ClientLibrary'] := Progdir + 'fbclient\fbclient.dll';
dbtest.username := su;
dbtest.password := sp;
dbtest.Database := getDBFileName(sDB);
dbtest.Server := getDBServerName(sDB);
dbtest.connected := true;
// If I quit here, the access violation occurs
Update: Following a suggestion from the Stackoverflow forum I traced the count index in system.pas to find the unit which is causing the problem by stepping into. Unfortunately the finalization routine causing the problem points into nirvana and not into any unit.
Environment: Delphi XE6 Enterprise, Firebird 2.5.4 embedded client connecting to Firebird 1.56 oder 2.54.
Any help would be very appreciated as I urgently have to track down a memory leak and cannot use fastMM wit this error;-(
Best regards Michael