Assertion failure: "(!" Setthreadcontext failed ")" Problem Solution

Source: Internet
Author: User
Document directory
  • Update 1
  • Update 2

After compiling and running the program, delphi2007 will prompt the following error (Windows 7 64-bit Runtime Environment ):

---------------------------
Bds.exe-bordbk105n. dll
---------------------------
Assertion failure :"(! "Setthreadcontext failed ")"
In .. \ win32src \ thread32.cpp at line 412
Continue execution?

---------------------------
Yes No
---------------------------

 

------- Gorgeous split line ---------

When Delphi 2007 or 2009 exits the IDE on Windows 7x64 and other x64 systems, the debugger will generate an asserted error.

Error window title: bds.exe-bordbk120n. dll, content: assertion failure: "(!" Setthreadcontext failed ")" in .. \ win32src \ thread32.cpp at line 434.

The solution is to use an unofficial patch for repair.

Patch Source: http://www.monien.net/blog/index.php/2009/07/delphi-2009-windows-7-64-bit-debugger-crash-workaround/

 

Delphi 2009/Windows 7/64 bit debugger crash
Workaround

 

Delphi 2009/Windows 7/64 bit debugger crash
Workaround

Yesterday I revisited a nasty problem that occurs on Windows 64bit versions. I ran into that when I upgraded to Windows 7, but it seems it affects older 64bit editions of windows as well.

After installing d2009 on a clean win7 machine I was happy to see that Windows 7 really is what Vista shoshould have been. it works snappy and has a lot of productivity features. but then when I started compiling and debugging a couple of my existing Delphi
Applications I experienced debugger crashes almost everytime when I terminated an application.


Unfortunately no matter if you press "yes" or "no" on that screen-you have to restart the whole Delphi ide-which basically makes debugging impossible. in some (actually compatible) cases you even have to terminate DELPHI using Windows TASKMANAGER. I tried all
Of the compatibility settings win7 offers, as well as running Delphi as administrator-but no luck.

Some research on Google, QC and raid showed that similar exceptions were reported with older Delphi versions, but apparently only on 64bit windows editions. as the message already suggests, the problem appears to be an invalid call to a setthreadcontext
API call. some tests showed that you can easily reproduce this issue once you have more that just a single thread in your Delphi application. as you might know, I am doing quite a lot of Web application server development-which by nature create multiple threads...

I created a raid entry for that (actually an existing one was updated with detailed reproduction steps-iirc) and joined a discussion thread on that topic to see if others are reporting that too. because of time constraints I did not revisit that issue
Over the last couple of weeks, but yesterday when I was talking
Daniel magin, we together found a solution someone had posted on
German Forum a few weeks ago. The original idea is from

MS technet posting though (credits go to a guy called

Xelax ).

He posted a workaround that basically disables the check for a possible error returned by setthreadcontext, I. e. the debugger ignores the error and does not crash because of the assert that checks fro no error returned. as
Andreas hausladen already correctly mentioned, this is really just kind of a weak workaround, because the debugger might misbehave after that and we just do not know
WhySetthreadcontext fails at all. the point is though that with this fix I can work together tively again with d2009 on win7/64bit and as this error only happens when the debugger is about to shout down anyway, so the danger of unwanted side effects
Is not too high IMHO.

Be careful! No waranties! I am not responsible for lost files etc .! Back up first!

Workaround steps:

  1. Close Delphi
  2. Locate bordbk120n. dll (c: \ Program Files (x86) \ codegear \ rad studio \ 6.0 \ bin)
  3. Make a backup copy
  4. Check step 3
  5. Open bordbk120n. dll in a hex Editor (ultraedit works fine)
  6. Search"01 00 48 74 47 80 3D"
  7. Make sure this is foundOnce only
  8. Replace"74"With"EB"
  9. Save
  10. Restart delphi. Error shoshould be gone.

This might work on older Delphi versions as well, but I did not test that yet.

Update 1

I talked to some codegear Q & A guy and he tested their current internal Weaver build under the conditions where d2009 fails. the good news is that the error seems to be gone there-so the next Delphi version will probably be good. for those who want to get
StartedNow: Please see Update 2 below.

Update 2

Lordbyte sent me his automatic patch tool for Delphi 2007 and Delphi 2009. Just click "Apply patch" and you are done.

Get the Patcher here:
Delphi_2007_2009_wow64_debugger_fix.zip (169 KB)

Note: provided as is for free. Use at your own risk.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.