none
"Module not found." Exception when starting application many times in a short period of time. RRS feed

  • Question

  • Background: I have a small program that runs for about less then a second and it can (depending on the configuration) end up running hundreds to thousands of times in 15 minutes. Occasionally I get the following sets of exceptions that result in a crash. The code seems to be all in the .NET process start up so I am having trouble debugging and handling the error.

    A crash message box titled: '<program name> - Application Error'
    Message: The exception unknown software exception (0xc06d007e) occurred in the application at location 0x7c812afb.

    Hitting Cancel lets me debug it in visual studio which gives this exception:

    Unhandled exception at 0x7c812afb (kernel32.dll) in <program name>: 0xC06d007E: Module not found.

    The stack trace looks like:

     kernel32.dll!_RaiseException@16()  + 0x52 bytes 
      mscoree.dll!___delayLoadHelper2@8()  + 0x3090c bytes 
      mscoree.dll!__tailMerge_SHLWAPI_dll()  + 0xd bytes 
      mscoree.dll!XMLGetVersionWithSupported()  + 0x1f bytes 
      mscoree.dll!RuntimeRequest::GetRuntimeVersion()  + 0x56 bytes 
      mscoree.dll!RuntimeRequest::ComputeVersionString()  + 0x29b bytes 
      mscoree.dll!RuntimeRequest::FindVersionedRuntime()  + 0x90 bytes 
      mscoree.dll!RuntimeRequest::RequestRuntimeDll()  - 0x28 bytes 
      mscoree.dll!GetInstallation()  - 0x9e bytes 
      mscoree.dll!__CorExeMain@0()  + 0x12 bytes 
      kernel32.dll!_BaseProcessStart@4()  + 0x23 bytes 


    Question(s):

    1) Does anyone know a way to handle this exception so the program doesn't crash?
    2) Does anyone know why its crashing during start up?
    3) Does anyone know a way to avoid the error in the first place (other then the obvious 'redesign your program').

    How to reproduce:

    I was able to reproduce this with two programs. The first has the following code in the Main function: Thread.Sleep(15000);

    The second program starts the first program ~750 times with System.Diagnostics.Process.Start.

    Thanks!

    Monday, August 31, 2009 6:19 PM

Answers

  • I dont think this is machine instability... some kind of internal limit on the number of child process that one parent can start is being hit (I have managed to recreate it as well on a few different winXP boxes). The dump analysis yields the following:

    ------------------------------------------------------------------------------------------------------------------------------------------------- 
    0:000> .ecxr
    eax=0012ec94 ebx=00000000 ecx=00000000 edx=00000007 esi=0012ed5c edi=00000000
    eip=7c812a5b esp=0012ec90 ebp=0012ece4 iopl=0         nv up ei pl nz na po nc
    cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000202
    KERNEL32!RaiseException+0x53:
    7c812a5b 5e              pop     esi
    0:000> kb
      *** Stack trace for last set context - .thread/.cxr resets it
    ChildEBP RetAddr  Args to Child              
    0012ece4 79037966 c06d007e 00000000 00000001 KERNEL32!RaiseException+0x53
    0012ed4c 790099ba 00000008 0012ed08 7c90eb94 mscoree!__delayLoadHelper2+0x139
    0012ed98 790075b1 001548f0 0012edac 0012fb34 mscoree!_tailMerge_SHLWAPI_dll+0xd
    0012edb0 79007623 001548f0 0012edf8 0012edf4 mscoree!XMLGetVersionWithSupported+0x22
    0012ee00 790069a4 b74bf8e9 00000000 000001fe mscoree!RuntimeRequest::GetRuntimeVersion+0x56
    0012f478 790077aa 00000001 7903fb4c 0012fb34 mscoree!RuntimeRequest::ComputeVersionString+0x5bd
    0012f89c 79007802 00000001 0012f8b4 7903fb4c mscoree!RuntimeRequest::FindVersionedRuntime+0x11c
    0012f8b8 79007b19 00000001 00000000 b74bf335 mscoree!RuntimeRequest::RequestRuntimeDll+0x2c
    0012ffa4 79007c02 00000001 0012ffbc 00000000 mscoree!GetInstallation+0x72
    0012ffc0 7c816fd7 00300036 00380031 7ffd5000 mscoree!_CorExeMain+0x12
    0012fff0 00000000 79007bf0 00000000 00000000 KERNEL32!BaseProcessStart+0x23
    -------------------------------------------------------------------------------------------------------------------------------------------------
    In the above trace, the exception code for the exception is: c06d007e 

    Since the exception is being raised even before the .NET application itself has started, there is no way of catching it (unless you write a native launcher which lauches the framework). You could try and modify your launcher application so that you start two instances of it and each lauches ~350 child processes ( I saw the error occuring around the 500th process although subsequent processes did start successfuly). You could also handle the Exited event in the System.Diagnostic.Process class:

    ----------------------------------------------------------------------------------------------------------------------------------------
                Process p = new Process();
                p.EnableRaisingEvents = true;
                p.Exited += new EventHandler(p_Exited);

    ----------------------------------------------------------------------------------------------------------------------------------------

    The exited event will allow you to look at the exit code and in case of a non zero exit code, you could try and restart the failed child process.
    • Proposed as answer by Ali A G Wednesday, September 2, 2009 11:56 AM
    • Marked as answer by eryang Thursday, October 8, 2009 8:46 AM
    Wednesday, September 2, 2009 11:12 AM

All replies

  • This looks like machine instability.  It is trying to load a delay-loaded DLL, a common Windows one named shlwapi.dll.  Mscoree.dll indeed has a dependency on it, probably the PathCombine() API function.  This should never fail.  You cannot catch this exception, it happens before managed code starts running.

    Focus on getting your machine stable again.  Disable stuff like virus scanners first.

    Hans Passant.
    Monday, August 31, 2009 7:37 PM
    Moderator
  • Thank you for your reply. I'm not entirely sure what you mean when you say the machine is unstable, since this happens on at least 3 machines at my company and disabling the anti-virus program would make the IT department very unhappy with me (and wouldn't be a solution for any customer that happens across the issue). I will however try your solution once I manage to disable the anti-virus.

    I agree with you that this should never fail and it works fine up until there is a relatively high load of the process being started. It seems to reach some threshold (I haven't tracked it down exactly, but its somewhere after the 500th time the process has beed started) and then fails consistently after that.
    Tuesday, September 1, 2009 1:37 PM
  • I dont think this is machine instability... some kind of internal limit on the number of child process that one parent can start is being hit (I have managed to recreate it as well on a few different winXP boxes). The dump analysis yields the following:

    ------------------------------------------------------------------------------------------------------------------------------------------------- 
    0:000> .ecxr
    eax=0012ec94 ebx=00000000 ecx=00000000 edx=00000007 esi=0012ed5c edi=00000000
    eip=7c812a5b esp=0012ec90 ebp=0012ece4 iopl=0         nv up ei pl nz na po nc
    cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000202
    KERNEL32!RaiseException+0x53:
    7c812a5b 5e              pop     esi
    0:000> kb
      *** Stack trace for last set context - .thread/.cxr resets it
    ChildEBP RetAddr  Args to Child              
    0012ece4 79037966 c06d007e 00000000 00000001 KERNEL32!RaiseException+0x53
    0012ed4c 790099ba 00000008 0012ed08 7c90eb94 mscoree!__delayLoadHelper2+0x139
    0012ed98 790075b1 001548f0 0012edac 0012fb34 mscoree!_tailMerge_SHLWAPI_dll+0xd
    0012edb0 79007623 001548f0 0012edf8 0012edf4 mscoree!XMLGetVersionWithSupported+0x22
    0012ee00 790069a4 b74bf8e9 00000000 000001fe mscoree!RuntimeRequest::GetRuntimeVersion+0x56
    0012f478 790077aa 00000001 7903fb4c 0012fb34 mscoree!RuntimeRequest::ComputeVersionString+0x5bd
    0012f89c 79007802 00000001 0012f8b4 7903fb4c mscoree!RuntimeRequest::FindVersionedRuntime+0x11c
    0012f8b8 79007b19 00000001 00000000 b74bf335 mscoree!RuntimeRequest::RequestRuntimeDll+0x2c
    0012ffa4 79007c02 00000001 0012ffbc 00000000 mscoree!GetInstallation+0x72
    0012ffc0 7c816fd7 00300036 00380031 7ffd5000 mscoree!_CorExeMain+0x12
    0012fff0 00000000 79007bf0 00000000 00000000 KERNEL32!BaseProcessStart+0x23
    -------------------------------------------------------------------------------------------------------------------------------------------------
    In the above trace, the exception code for the exception is: c06d007e 

    Since the exception is being raised even before the .NET application itself has started, there is no way of catching it (unless you write a native launcher which lauches the framework). You could try and modify your launcher application so that you start two instances of it and each lauches ~350 child processes ( I saw the error occuring around the 500th process although subsequent processes did start successfuly). You could also handle the Exited event in the System.Diagnostic.Process class:

    ----------------------------------------------------------------------------------------------------------------------------------------
                Process p = new Process();
                p.EnableRaisingEvents = true;
                p.Exited += new EventHandler(p_Exited);

    ----------------------------------------------------------------------------------------------------------------------------------------

    The exited event will allow you to look at the exit code and in case of a non zero exit code, you could try and restart the failed child process.
    • Proposed as answer by Ali A G Wednesday, September 2, 2009 11:56 AM
    • Marked as answer by eryang Thursday, October 8, 2009 8:46 AM
    Wednesday, September 2, 2009 11:12 AM
  • Can you please activate some performance counters to see how many process are being spawned to see if there's a limit beyond which this error is happening and as Ali has suggested, if you use a custom launcher app, then calling p.Start might throw an exception which can show us show more information. Also, look at what other applications are running at the same time.


    Mahesh
    Wednesday, September 2, 2009 9:08 PM
  • It's not a bad theory.  Easy to diagnose too, run Taskmgr.exe, Processes tab.

    Hans Passant.
    Wednesday, September 2, 2009 10:32 PM
    Moderator
  • Process.Start does not report any errors.

    nobugz: The problem occurs with or without anti-virus.

    I'm going to try and get a more exact process count today, it is definetely more then 500 and less then 750. There are a lot of applications running on my machine... usually between 50 and 60 processes total. They tend to include IE8, outlook, sql visual studio, etc.

    Thursday, September 3, 2009 4:28 PM
  • You are right, Process.Start will not return the error as the error occurs when the child process itself is started. Process.Start is not designed to report any error other than the exit code of the application. Although you can use the HasExited property of the Process object to see what state the process is in.
    Thursday, September 3, 2009 4:32 PM
  • Had same problem - it turned out that processes fail to start due to desktop heap exhaustion.

    http://support.microsoft.com/kb/184802/en-us

    Wednesday, March 14, 2012 3:07 PM