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.
Hey thanks a lot! I actually just got my super-workstation Windows 2008 R2 up and running and this is one of the few wacky things that annoyed me!
ReplyDeleteThank you so much!!
ReplyDeleteIt only started recently for me, and only in some of my projects, but it was really annoying having to build and then run through Explorer every time to avoid the crash. Horribly inefficient...
Thanks a bunch! Was driving me mad!!
ReplyDeleteWorked great also for C++ Builder 2007..
Thanks loads! I had to update a few Delphi 2007 projects and this was driving me nuts!
ReplyDeleteThe projects are not worth porting to Delphi 2010, but it would be nice if we could still support them with 2007. I have to admit for any new development we have had to dump Delphi all together. After we got screwed with the change to Prism we decided that it just was not worth it.
Worked for me perfectly for Delphi 2007 on Windows 7 64bit machine. Thank you a lot for sharing.
ReplyDeleteHey, thank you for the post. Works perfectly on windows 7 x64
ReplyDeleteoffical Hotfix 2 fix the problem
ReplyDeleteBig Thanks from Belorussia!
ReplyDeleteA ton of thanks from Spain, dude! You are the man!
ReplyDeleteA ton of thanks from Spain, dude! You are the man!
ReplyDeleteI think the download link isnt working. Has anyone else got it?
ReplyDeleteDavid Bolton
David, I updated the link to reflect the new location (thank you Internet Search Engines!). I no longer use Delphi and have not verified that it will still work.
ReplyDelete