程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> Delphi >> Assertion failure: "(!"SetThreadContext fa

Assertion failure: "(!"SetThreadContext fa

編輯:Delphi

在編譯程序並運行後,Delphi2007會提示以下錯誤(windows 7 64位 運行環境):
 
---------------------------
bds.exe - bordbk105N.dll
---------------------------
Assertion failure: "(!"SetThreadContext failed")"
in ..\win32src\thread32.cpp at line 412
Continue execution?
 
---------------------------
Yes   No  
---------------------------
 
 
 
———————華麗的分割線————————-
 
Delphi 2007 或2009 在Windows 7 x64 以及其他x64 系統下,退出IDE 時,調試器會產生一個斷言錯誤。
 
 \
 
錯誤窗口標題為:bds.exe –bordbk120N.dll,內容為:Assertion failure: “(!”SetThreadContext failed”)”in ..\win32src\thread32.cpp at line 434。
 
解決辦法是使用一個非官方的補丁程序進行修復。
 
 \
 
補丁程序來源: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 should 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.
 
 image
 
 
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 many) 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 many 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 to Daniel Magin, we together found a solution someone had posted on a German Forum a few weeks ago. The original idea is from an MS TechNet posting though (credits go to a guy called Xelax Ax).

 
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 why SetThreadContext fails at all. The point is though that with this fix I can work effectively 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:
 
Close Delphi
Locate bordbk120N.dll (C:\Program Files (x86)\CodeGear\RAD Studio\6.0\bin)
Make a backup copy
Check step 3
Open bordbk120N.dll in a Hex editor (UltraEdit works fine)
Search for “01 00 48 74 47 80 3D”
Make sure this is found once only
Replace “74” with “EB”
Save
Restart Delphi. Error should 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 started now: 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.
 image
 
 
Get the patcherhere: Delphi_2007_2009_WOW64_Debugger_Fix.zip (169 KB)
 
Note: Provided as is for free. Use at your own risk.


摘自 冷月宮主的專欄

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved