<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>.NET Crash: Managed Heap Corruption calling unmanaged code</title><link>http://blogs.msdn.com/tess/archive/2006/02/09/net-crash-managed-heap-corruption-calling-unmanaged-code.aspx</link><description>If someone asked me, what is the nastiest types of issues you get? I would say managed heap corruption, closely followed by native heap corruption. Btw, if you are new to debugging .net issues with windbg this case study might not be the best one to start</description><dc:language>sv-SE</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: .NET Crash: Managed Heap Corruption calling unmanaged code</title><link>http://blogs.msdn.com/tess/archive/2006/02/09/net-crash-managed-heap-corruption-calling-unmanaged-code.aspx#540785</link><pubDate>Tue, 28 Feb 2006 23:09:32 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:540785</guid><dc:creator>rmbyers</dc:creator><description>For situations like this, it's still hard to tell where the corruption is occuring. &amp;nbsp;In this case, the contents of the buffer provided a hint, but that's not always going to help. &amp;nbsp;One thing that may help is to use !gcroot on the last good object (the byte[10] in this case) - if the object is still alive, it root path should give an indication of where in the source code this object is being held (and therefore where it is being used). &amp;nbsp;Often by looking at how the specific object is being used in the source, you can quickly find some suspect PInvoke or other call which could be causing the corruption.&lt;br&gt;&lt;br&gt;In the long run, my team (CLR debugging support) would like to enable &amp;quot;time-traveling debugging&amp;quot; where you could record an execution trace (if the repro scenario permits) , and then just say &amp;quot;go back to the spot where this memory was overwritten&amp;quot;. &amp;nbsp;In some cases like this, it could make tracking down these sorts of problems extremely easy!</description></item><item><title>re: .NET Crash: Managed Heap Corruption calling unmanaged code</title><link>http://blogs.msdn.com/tess/archive/2006/02/09/net-crash-managed-heap-corruption-calling-unmanaged-code.aspx#541130</link><pubDate>Wed, 01 Mar 2006 11:05:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:541130</guid><dc:creator>Tess</dc:creator><description>Thanks for pointing out !gcroot, these isssues are definitely not among the easier ones to get to the bottom of. &lt;br&gt;&lt;br&gt;I, for one, am really excited about the &amp;quot;time-traveling debugging&amp;quot;. I really cant wait to see it. &lt;br&gt;&lt;br&gt;Currently if we cant find the fault using the steps above or with gcroot like Rick mentions, we have to run something called GCStress which essentially triggers a gc on each allocation so we get the exception closer to the faulting call, but of course as you can imagine this is really bad performance wise so it cant generally be done in production. &amp;nbsp;And this is why im doubly excited about the time travelling stuff... &amp;nbsp;plus, anything involving the word time-travel just has to be exciting right:)</description></item></channel></rss>