After extinsive debug (with debug DCU's enabled), it became apparent that this was a Delphi design problem.
I hypothesize that the problem was originally caused by high network traffic - backups and the like - causing the two machines to loose communication for a short time. I know that the problem is also caused when the system administrators automatically reboot the database machine and when a network switch becomes unavailable.
Obviously, I tried wrapping the code in Try..Except blocks, but those had no effect ... the program would just crash (stop running).
For additional test, I created a simple program in Delphi 5 / IBX 5.04, and it simply displayed an error when I stopped Firebird. Recompiling the exact same source in Delphi 6 reproduced the crash.
Delphi 6 IDE Failure
Project xyz.exe faulted with message: 'access violation at 0x...: write of address 0x00030FD8. Process stopped. Use Step or Run to continue.Of course, neither Step nor Run were of any use ... they just repeated the same message.
The debugger stopped on this in the assembler
fbclient.isc_dsql_free_statement ... sub esp, $50 ... push ebx -- This line fails, ESP = 00030FD8Since stack problems are almost never caused by the programmer's code, it is an almost sure sign of a compiler design problem.
IBX 6.08 for Delphi 6
This is from the Read Me file.
30. IBDatabase - better support for loss of connection. Should no longer stack overflow and everything is properly closed. The actual message though is not always a lost connection error message.This sounds exactly like the problem I was having.
After installation, I had problems with a few packages I had written (as warned in the Read Me file) - simply recompilling the packages fixed these.
After installation and a recompile, the crash problem fixed.
If the database is no longer connected, then the Connected property should be automatically cleared.
I have a manual patch for that (pretty sloppy by any standard - this should be a part of the component).
There appear to be multible related errors ...
*.exe file size - same program compiled with different compilers and IBX versions
|D5 SP1 IBX 5.04
|D6 UP2 IBX 6.08