Ask a questionAsk a question
 

QuestionMDA 'LoaderLock' report unreliable?

  • Friday, November 06, 2009 2:47 PMPhil Atkin Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I have a managed (C#) app calling a mixed (managed/unmanaged) class library written in C++, which in turn is calling methods on an in-process COM object, which loads a DLL.
    All is fine until, in response to a mouse click, I call a method on the COM object that causes it to call FreeLibrary on the bottom-level DLL.  During the execution of FreeLibrary, I get an MDA 'LoaderLock' pop up.  The additional information provided says "Attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang".  Since the DLL is a 'plain C' DLL, and pre-dates .Net, I do not think it likely that it could be trying to run any managed code (the call stack and stepping through the disassembly tends to support my view).

    Is it possible that the debugging assistant is detecting some other 'not recommended' behaviour of the DLL as it executes DllMain, but is misreporting it as an attempt to execute managed code?

All Replies