<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Olaf's Thoughts About Development &#187; debugger crash</title>
	<atom:link href="http://www.monien.net/blog/index.php" rel="self" type="application/rss+xml" />
	<link>http://www.monien.net/blog</link>
	<description>Delphi Programming, .NET Philosophy, Web development and more ...</description>
	<lastBuildDate>Mon, 14 Mar 2011 15:59:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Delphi 2009 / Windows 7 / 64 bit Debugger Crash Workaround</title>
		<link>http://www.monien.net/blog/index.php/2009/07/delphi-2009-windows-7-64-bit-debugger-crash-workaround/</link>
		<comments>http://www.monien.net/blog/index.php/2009/07/delphi-2009-windows-7-64-bit-debugger-crash-workaround/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 08:44:15 +0000</pubDate>
		<dc:creator>Olaf Monien</dc:creator>
				<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[CodeGear]]></category>
		<category><![CDATA[debugger crash]]></category>
		<category><![CDATA[win 64]]></category>
		<category><![CDATA[Windows 7]]></category>

		<guid isPermaLink="false">http://www.monien.net/blog/index.php/2009/07/delphi-2009-windows-7-64-bit-debugger-crash-workaround/</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p>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.</p>
<p>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.</p>
<p><a href="http://www.monien.net/blog/wp-content/uploads/2009/07/image2.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.monien.net/blog/wp-content/uploads/2009/07/image-thumb.png" width="244" height="128" /></a></p>
<p><span id="more-257"></span><br />
Unfortunately no matter if you press “Yes” or “No” on that screen &#8211; 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.
</p>
<p>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…</p>
<p>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 <a href="http://dmagin.wordpress.com/">Daniel Magin</a>, we together found a solution someone had posted on a <a href="http://www.delphipraxis.net/topic157103,0,asc,15.html" target="_blank">German Forum</a> a few weeks ago. The original idea is from an <a href="http://social.technet.microsoft.com/Forums/en-US/w7itproappcompat/thread/e56df407-bd0b-4ecc-b8a5-0a35bcd571cc" target="_blank">MS TechNet posting</a> though (credits go to a guy called <a href="http://social.technet.microsoft.com/Profile/en-US/?user=Xelax%20Ax&amp;referrer=http%3a%2f%2fsocial.technet.microsoft.com%2fForums%2fen-US%2fw7itproappcompat%2fthread%2fe56df407-bd0b-4ecc-b8a5-0a35bcd571cc&amp;rh=brADRQTrMvvH8l6aPUv7nuhgDfkf2IwL37bbQj6SzUo%3d&amp;sp=forums" target="_blank">Xelax Ax</a>).</p>
<p>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 <a href="http://andy.jgknet.de/blog/" target="_blank">Andreas Hausladen</a> 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 <strong>why </strong>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.</p>
<p><strong><span style="color: #ff0000">Be careful! No waranties! I am not responsible for lost files etc.! Back up first!</span></strong></p>
<p><em><strong>Workaround steps:</strong></em></p>
<ol>
<li>Close Delphi </li>
<li>Locate bordbk120N.dll (C:\Program Files (x86)\CodeGear\RAD Studio\6.0\bin) </li>
<li>Make a backup copy </li>
<li>Check step 3 </li>
<li>Open bordbk120N.dll in a Hex editor (<a href="http://www.ultraedit.com/" target="_blank">UltraEdit</a> works fine) </li>
<li>Search for <strong>“01 00 48 <span style="color: #ff0000">74</span> 47 80 3D</strong>” </li>
<li>Make sure this is found <strong>once only</strong> </li>
<li>Replace “<strong><span style="color: #ff0000">74</span></strong>” with&#160; “<strong>EB</strong>” </li>
<li>Save </li>
<li>Restart Delphi. Error should be gone. </li>
</ol>
<p>This might work on older Delphi versions as well, but I did not test that yet.</p>
<h3>Update 1</h3>
<p>I talked to some CodeGear Q&amp;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 <strong>now</strong>: please see Update 2 below.</p>
<h3>Update 2</h3>
<p><a href="http://disqus.com/people/b4d557243a4ed3732a93e9399f9922fa/" target="_blank">LordByte</a> sent me his automatic patch tool for Delphi 2007 and Delphi 2009. Just click “Apply patch” and you are done.</p>
<p><a href="http://www.monien.net/blog/wp-content/uploads/2009/07/image4.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.monien.net/blog/wp-content/uploads/2009/07/image-thumb2.png" width="244" height="154" /></a> </p>
<p>Get the patcher here: <a href="http://www.monien.biz/blog/wp-content/uploads/2009/07/Delphi_2007_2009_WOW64_Debugger_Fix.zip" target="_blank">Delphi_2007_2009_WOW64_Debugger_Fix.zip</a> (169 KB)</p>
<p>Note: Provided as is for free. Use at your own risk.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-knowledge">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://www.shareaholic.com/api/share/?title=Delphi+2009+%2F+Windows+7+%2F+64+bit+Debugger+Crash+Workaround&amp;link=http://www.monien.net/blog/index.php/2009/07/delphi-2009-windows-7-64-bit-debugger-crash-workaround/&amp;notes=Yesterday%20I%20revisited%20a%20nasty%20problem%20that%20occurs%20on%20Windows%2064bit%20versions.%20I%20ran%20into%20that%20when%20I%20upgraded%20to%20Windows%207%2C%20but%20it%20seems%20it%20affects%20older%2064bit%20editions%20of%20Windows%20as%20well.%20%20After%20installing%20D2009%20on%20a%20clean%20Win7%20machine%20I%20was%20happy%20to%20see%20that%20Windows%207%20really%20is%20what%20Vista%20should%20ha&amp;short_link=&amp;shortener=tinyurl&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=%24%7Btitle%7D+-+%24%7Bshort_link%7D&amp;service=7&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://www.monien.net/blog/index.php/2009/07/delphi-2009-windows-7-64-bit-debugger-crash-workaround/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://www.shareaholic.com/api/share/?title=Delphi+2009+%2F+Windows+7+%2F+64+bit+Debugger+Crash+Workaround&amp;link=http://www.monien.net/blog/index.php/2009/07/delphi-2009-windows-7-64-bit-debugger-crash-workaround/&amp;notes=Yesterday%20I%20revisited%20a%20nasty%20problem%20that%20occurs%20on%20Windows%2064bit%20versions.%20I%20ran%20into%20that%20when%20I%20upgraded%20to%20Windows%207%2C%20but%20it%20seems%20it%20affects%20older%2064bit%20editions%20of%20Windows%20as%20well.%20%20After%20installing%20D2009%20on%20a%20clean%20Win7%20machine%20I%20was%20happy%20to%20see%20that%20Windows%207%20really%20is%20what%20Vista%20should%20ha&amp;short_link=&amp;shortener=tinyurl&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=2&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://www.shareaholic.com/api/share/?title=Delphi+2009+%2F+Windows+7+%2F+64+bit+Debugger+Crash+Workaround&amp;link=http://www.monien.net/blog/index.php/2009/07/delphi-2009-windows-7-64-bit-debugger-crash-workaround/&amp;notes=Yesterday%20I%20revisited%20a%20nasty%20problem%20that%20occurs%20on%20Windows%2064bit%20versions.%20I%20ran%20into%20that%20when%20I%20upgraded%20to%20Windows%207%2C%20but%20it%20seems%20it%20affects%20older%2064bit%20editions%20of%20Windows%20as%20well.%20%20After%20installing%20D2009%20on%20a%20clean%20Win7%20machine%20I%20was%20happy%20to%20see%20that%20Windows%207%20really%20is%20what%20Vista%20should%20ha&amp;short_link=&amp;shortener=tinyurl&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=3&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.shareaholic.com/api/share/?title=Delphi+2009+%2F+Windows+7+%2F+64+bit+Debugger+Crash+Workaround&amp;link=http://www.monien.net/blog/index.php/2009/07/delphi-2009-windows-7-64-bit-debugger-crash-workaround/&amp;notes=Yesterday%20I%20revisited%20a%20nasty%20problem%20that%20occurs%20on%20Windows%2064bit%20versions.%20I%20ran%20into%20that%20when%20I%20upgraded%20to%20Windows%207%2C%20but%20it%20seems%20it%20affects%20older%2064bit%20editions%20of%20Windows%20as%20well.%20%20After%20installing%20D2009%20on%20a%20clean%20Win7%20machine%20I%20was%20happy%20to%20see%20that%20Windows%207%20really%20is%20what%20Vista%20should%20ha&amp;short_link=&amp;shortener=tinyurl&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=257&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-reddit">
			<a href="http://www.shareaholic.com/api/share/?title=Delphi+2009+%2F+Windows+7+%2F+64+bit+Debugger+Crash+Workaround&amp;link=http://www.monien.net/blog/index.php/2009/07/delphi-2009-windows-7-64-bit-debugger-crash-workaround/&amp;notes=Yesterday%20I%20revisited%20a%20nasty%20problem%20that%20occurs%20on%20Windows%2064bit%20versions.%20I%20ran%20into%20that%20when%20I%20upgraded%20to%20Windows%207%2C%20but%20it%20seems%20it%20affects%20older%2064bit%20editions%20of%20Windows%20as%20well.%20%20After%20installing%20D2009%20on%20a%20clean%20Win7%20machine%20I%20was%20happy%20to%20see%20that%20Windows%207%20really%20is%20what%20Vista%20should%20ha&amp;short_link=&amp;shortener=tinyurl&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=40&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-technorati">
			<a href="http://www.shareaholic.com/api/share/?title=Delphi+2009+%2F+Windows+7+%2F+64+bit+Debugger+Crash+Workaround&amp;link=http://www.monien.net/blog/index.php/2009/07/delphi-2009-windows-7-64-bit-debugger-crash-workaround/&amp;notes=Yesterday%20I%20revisited%20a%20nasty%20problem%20that%20occurs%20on%20Windows%2064bit%20versions.%20I%20ran%20into%20that%20when%20I%20upgraded%20to%20Windows%207%2C%20but%20it%20seems%20it%20affects%20older%2064bit%20editions%20of%20Windows%20as%20well.%20%20After%20installing%20D2009%20on%20a%20clean%20Win7%20machine%20I%20was%20happy%20to%20see%20that%20Windows%207%20really%20is%20what%20Vista%20should%20ha&amp;short_link=&amp;shortener=tinyurl&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=10&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
</ul><div style="clear: both;"></div><div class="shr-getshr" style="visibility:hidden;font-size:10px !important"><a target="_blank" href="http://www.shareaholic.com/?src=pub">Get Shareaholic</a></div><div style="clear: both;"></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.monien.net/blog/index.php/2009/07/delphi-2009-windows-7-64-bit-debugger-crash-workaround/feed/</wfw:commentRss>
		<slash:comments>128</slash:comments>
		</item>
	</channel>
</rss>

