Possible APPCRASH causes?

I have a weird issue whereby my server crashes with an APPCRASH error when close the application. This is when running it as a standalone app rather than a service and only within the Delphi IDE. I’ve done some testing and oddly, this only happens if I’ve actually performed some data access. If I simply start the server and close it immediately then all is well but if I start it and open and close a data table, then the crash occurs when I close the application.

I’m not sure if this is somehow related to threads. I’ve noticed that, the first time I open a data table, quite a few threads are created and remain active. I presume this is normal. Is it possible that some of these threads are not terminating properly when the application closes?

I’m clutching at straws here and wondering if anyone has any ideas on how I can debug this error as there’s virtually no information and I don’t seem to be able to trap it at all.

Any help appreciated.

It looks like this might have something to do with Indy.

If I trace through the shutdown process then it appears the crash occurs when the TIdThread.Execute function exits.

Oddly, if I trace through in the IDE quickly (i.e. hitting F8 as fast as I can) then it will usually happen at this point, but if I trace through the Execute function slowly (such as hitting F8 once a second) then it often works.

Looks like some kind of timing issue with threads, like something isn’t being given the chance to terminate properly when the app is run normally or debugged quickly, whereas if I trace through slowly it does.

Ignore me - it was due to my not installing Delphi 2010 Update 4 after a recent reinstallation. Doing so cured the problem.