ksjoberg
Apr 13, 2011
  25279
(6 votes)

Debugging a 64-bit dump of a 32-bit managed process

You may wonder: why on earth would you want to do that? Well, on 64-bit machines, 32-bit processes are run using a WOW64 compatibility layer to provide the 32-bit process with the appropriate entry-points and map them to the 64-bit equivalents.

imageHowever, when you use Windows Vista's (and later) Create Dump File, you will create a dump of the process that includes the WOW64 compatibility layer. The dump file thus contain both 64-bit and 32-bit code.

If you open this dump in WinDbg (x64), it seems to load just fine. Then, to start managed debugging, you will want to load the debugging extension SOS. A convenient command to load the correct version of SOS (which must be the same version as the version of .NET Framework that you intend to debug) is to type the command

.loadby sos mscorwks

into the WinDbg command window. This will load SOS.dll from the same directory on your local machine, as mscorwks.dll was loaded from (in the debugee). (Note that you will need to exchange mscorwks with clr to debug a .NET4 debugee)

However, in this case you will get errors such as:

0:000> .loadby sos mscorwks
The call to LoadLibrary(C:\Windows\Microsoft.NET\Framework\v2.0.50727\sos) failed, Win32 error 0n193
    "%1 is not a valid Win32 application."
Please check your debugger configuration and/or network access.

There is some interesting information we can derive from this error message. Since the path (C:\Windows\Microsoft.NET\Framework) points to the 32-bit version of SOS.dll, the mscorwks.dll in the dump must also be a 32-bit binary (the 64-bit version of .NET Framework is in the Framework64 folder). And since we're running the 64-bit version of WinDbg and we try to load a 32-bit SOS, we will need to start a compatible version of WinDbg instead.

Reopening the dump in WinDbg (x86) and loading the SOS managed debugging extension works just fine. However, you will find that it doesn't work when you issue any of the SOS commands: !CLRStack, !DumpHeap, !EEStack:

0:000> !clrstack
Failed to load data access DLL, 0x80004005
Verify that 1) you have a recent build of the debugger (6.2.14 or newer)
            2) the file mscordacwks.dll that matches your version of mscorwks.dll is
                in the version directory
            3) or, if you are debugging a dump file, verify that the file
                mscordacwks_<arch>_<arch>_<version>.dll is on your symbol path.
            4) you are debugging on the same architecture as the dump file.
                For example, an IA64 dump file must be debugged on an IA64
                machine.
You can also run the debugger command .cordll to control the debugger's
load of mscordacwks.dll.  .cordll -ve -u -l will do a verbose reload.
If that succeeds, the SOS command should work on retry.
If you are debugging a minidump, you need to make sure that your executable
path is pointing to mscorwks.dll as well.

Drats!

There's a workaround for this, though. Issue the command

0:000> !wow64exts.sw
Switched to 32bit mode

And voila!

0:000:x86> !clrstack
OS Thread Id: 0x1b40 (0)
Failed to start stack walk: 80070057

Another failure...

However, other commands have started to work! Among them EEStack which prints the stack trace for all active threads, with managed and unmanaged code interleaved. This will have to do.

If you're able, capture dumps of 32-bit processes with a 32-bit debugger such as the 32-bit ADPlus part of the x86 version of Debugging Tools for Windows.

Happy debugging!

Apr 13, 2011

Comments

Apr 14, 2011 01:16 PM

I've been waiting for this blog. Great to have on epi world.

Please login to comment.
Latest blogs
Opti ID overview

Opti ID allows you to log in once and switch between Optimizely products using Okta, Entra ID, or a local account. You can also manage all your use...

K Khan | Jul 26, 2024

Getting Started with Optimizely SaaS using Next.js Starter App - Extend a component - Part 3

This is the final part of our Optimizely SaaS CMS proof-of-concept (POC) blog series. In this post, we'll dive into extending a component within th...

Raghavendra Murthy | Jul 23, 2024 | Syndicated blog

Optimizely Graph – Faceting with Geta Categories

Overview As Optimizely Graph (and Content Cloud SaaS) makes its global debut, it is known that there are going to be some bugs and quirks. One of t...

Eric Markson | Jul 22, 2024 | Syndicated blog

Integration Bynder (DAM) with Optimizely

Bynder is a comprehensive digital asset management (DAM) platform that enables businesses to efficiently manage, store, organize, and share their...

Sanjay Kumar | Jul 22, 2024

Frontend Hosting for SaaS CMS Solutions

Introduction Now that CMS SaaS Core has gone into general availability, it is a good time to start discussing where to host the head. SaaS Core is...

Minesh Shah (Netcel) | Jul 20, 2024

Optimizely London Dev Meetup 11th July 2024

On 11th July 2024 in London Niteco and Netcel along with Optimizely ran the London Developer meetup. There was an great agenda of talks that we put...

Scott Reed | Jul 19, 2024