The error was thrown by bordbk105N.dll and had the following text:
Assertion failure: "(!"SetThreadContext failed")"That was followed by a “Yes/No” set of buttons. It didn’t matter which choice you made, it was pretty much game over for Delphi at this point. After getting this happen 3 times in a row (even with Delphi launched with “Run As Administrator”), I decided to check the Internet and see if this was unique to me and if there was a fix.
in ..\win32src\thread32.cpp at line 412
Continue execution?
I checked Google and found a few hits. One of them led me to a blog written by Olaf Monien, a German developer with close ties to the Delphi R & D department. His post, “Delphi 2009 / Windows 7 / 64 bit Debugger Crash Workaround”, described the issue in great detail. Apparently an incorrect call is being made to the SetThreadContext API call. The debugger dll has an assert call based on the return value SetThreadContext(). It’s odd that production code went out with asserts enable, that’s usually used during testing. Some people traced through the debugger code and found that if a single byte is changed in the dll, you could get by this error. This byte changes the logic so it ignores the return code from SetThreadContext() and never hits the assert code. You can read about how they came up with that idea here.
An enterprising programmer named “LordByte” wrote a handy little utility that will patch the debugger dll for both Delphi 2007 and Delphi 2009.
[Edited April 22nd, 2013]
While I no longer use Delphi, I hate to see a broken link. I updated the download link for the debugger patch to it's current home at Embarcadero.