Welcome to MSDN Blogs Sign in | Join | Help

How to Disable a Specific MDA

How to Disable a Specific MDA

As Mike Stall has noted in his post, the PInvokeStackImbalance MDA can be very slow, depending on the number of pinvoke calls in an application.  Recently, we have had a few customers running into this issue, but MSDN does not give much information regarding disabling MDAs except for setting COMPLUS_MDA to 0 or setting the registry key to 0.  The problem with these options is that they disable all MDAs.  Moreover, if you set the registry key, it has machine-wide impact.

 

There is actually a more fine-grained approach to do this.  You can actually disable an MDA using an MDA configuration file.  However, as mentioned on MSDN and in Stephen Toub’s article, the CLR will not look for the MDA configuration file unless either the environment variable or the registry key is set 1.  Doing so has no effect if an application has no MDA configuration file.

 

For example, to disable the PInvokeStackImbalance MDA, you can do this:

 

1)      Set the COMPLUS_MDA environment variable to 1 (or equivalently, set HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\MDA to “1”)

 

2)      Assuming your application is called hello.exe, create hello.exe.mda.config in the same directory and put the following XML in it:

 

<?xml version="1.0" encoding="UTF-8" ?>

 

<mdaConfig>

  <assistants>

    <pInvokeStackImbalance enable="false"/>

  </assistants>

</mdaConfig>

 

 

Note that MDA configuration files have precedence over MDAs activated by default for the managed debugger and the unmanaged debugger.  This means that an MDA configuration file can disable an MDA which is enabled automatically because a debugger is attached.  (In fact, it is the only way.)

 

Due to an oversight, the PInvokeStackImbalance MDA is not even defined on 64-bit (both X64 and IA64) platforms.  So if you try to use the MDA configuration file above on 64-bit platforms, you will get an error.  But then again, since we only have one calling convention on X64 and one on IA64, why would you need this MDA on 64-bit platforms anyway?  ;)  

Published Thursday, June 15, 2006 7:46 AM by tlai
Filed under:

Comments

# Thomas Lai is now blogging!

Thomas Lai is now blogging! Thomas works on the CLR Debugging Services, along with other bloggers Rick...
Tuesday, June 20, 2006 11:36 AM by Mike Stall's .NET Debugging Blog

# Possible slowdowns under a debugger

Here's a list of things that may slow down execution under a debugger. I've seen a few threads go by

Monday, October 23, 2006 12:02 PM by Mike Stall's .NET Debugging Blog

# re: How to Disable a Specific MDA

What is the effect of disabling MDA using the registry key for Release build versions?

Are applications built in Release mode affected by this setting?

Thanks.

Monday, March 05, 2007 9:52 AM by mcanti

# Visual Studio Debugger FAQ

Introduction This FAQ can be used to narrow down the problems associated with debugging any type of solution

Tuesday, August 07, 2007 4:17 PM by Gooey Bugs
Anonymous comments are disabled
 
Page view tracker