Access Violation and InvalidDeploymentException RRS feed

  • Question

  • Hi


    I have a strange problem with an application that works on x86 Windows XP and Vista. On Vista X64, it crashes randomly and I'm unable to determine the cause. I'm not sure whether its the move from 32 to 64 bit or single to multi-processor, as my 64 bit Vista runs on a quad-core.


    I've collected numerous minidumps using adplus as Visual Studio 2005 is unable to debug the problem (the application just hangs and VS cannot break execution).


    The application simulates a hardware device that communicates via the serial port. As such, it opens 2 serial ports using System.IO.Ports.SerialPort. It receives a message on each serial port every 100ms. The message is a text message. It is interpreted and a text response is generated and sent back. There is therefore a lot of string parsing and I make heavy use of StringBuilders. I also do some tracing via System.Diagnostics.TraceSource. The application is a Windows Forms application that shows the state of internal objects using PropertyGrids.



    I opened the minidumps in windbg, loaded SOS and ran the following:



    ~*e !clrstack

    !analyze -v


    From the above, I've determined the following: Thread 0 (the main thread) always has a System.Deployment.Application.InvalidDeploymentException and the stack trace is:

    System.Windows.Forms.Application+ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32, Int32, Int32)
    System.Windows.Forms.Application+ThreadContext.RunMessageLoopInner(Int32, System.Windows.Forms.ApplicationContext)
    System.Windows.Forms.Application+ThreadContext.RunMessageLoop(Int32, System.Windows.Forms.ApplicationContext)


    One of my processing threads (there is one per serial port) is shown to be the active thread and is busy working with a string, either processing a messages or tracing. The exact stack trace is different every time.


    Analyze -v reports the following (everything here, except the managed stack is the same for all crashes):

    00000642`7f500a5d 488b00          mov     rax,qword ptr [rax]

    EXCEPTION_RECORD:  ffffffffffffffff -- (.exr ffffffffffffffff)
    ExceptionAddress: 000006427f500a5d (mscorwks!HelperMethodFrame::UpdateRegDisplay+0x000000000000005d)
       ExceptionCode: c0000005 (Access violation)
      ExceptionFlags: 00000000
    NumberParameters: 2
       Parameter[0]: 0000000000000000
       Parameter[1]: 0000000000000001
    Attempt to read from address 0000000000000001

    PROCESS_NAME:  Gendac.Grintek.Kbss.SfeSimulator.exe

    ERROR_CODE: (NTSTATUS) 0xc0000005 - The instruction at 0x%08lx referenced memory at 0x%08lx. The memory could not be %s.

    READ_ADDRESS:  0000000000000001



    The top of the unmanages stack trace is:
    mscorwks!Thread:Tongue TiedtackWalkFramesEx+0xd23
    mscorwks!Thread:Tongue TiedtackWalkFrames+0x9d
    mscorwks!WKS::gc_heap:Stick out tonguelan_phase+0x7e8


    What else can I try to determine the fault?



    Thursday, February 7, 2008 3:28 PM


  • The garbage collector is crashing while it is analyzing the thread's stack for live object references.  Could be a corrupted stack but that shouldn't happen when you use the managed SerialPort class.  You'll have to contact Microsoft CSS for support.
    • Marked as answer by nobugz Sunday, June 8, 2008 3:00 PM
    Wednesday, May 21, 2008 11:33 AM

All replies

  • I'm getting something very similar - I am reading a single serial port constantly, about twice per second.  Crash happens at an unpredictable time, usually several hours. I'm using XP 64bit, on a dual-core machine.  Haven't tested on a 32bit machine yet. 


    Here's what I'm getting (looks like the same thing as yours)


    (cb0.898): Access violation - code c0000005 (first/second chance not available)


    00000642`7f500a5d 488b00          mov     rax,qword ptr [rax] ds:00000000`00000001=????????????????

    0:006> kb 100

    RetAddr           : Args to Child                                                           : Call Site

    00000642`7f531fc3 : 00000000`1af3f248 00000000`00000500 00000000`002b3ea0 00000642`783405d3 : mscorwks!HelperMethodFrame::UpdateRegDisplay+0x5d

    00000642`7f513319 : 00000000`1af3f480 00000642`780eeac8 00000000`002a1b90 00000000`00000500 : mscorwks!Thread:Tongue TiedtackWalkFramesEx+0xd23

    00000642`7f52f7be : 00000642`7f50a188 00000642`7f50a1f0 00000000`00270b00 00000642`7f50a5a7 : mscorwks!Thread:Tongue TiedtackWalkFrames+0x9d

    00000642`7f4f878c : 00000000`02a4d610 00000000`00000001 00000000`00000000 00000000`02a4d610 : mscorwks!CNameSpace::GcScanRoots+0x1ae

    00000642`7f4fe928 : 00000000`02c4d660 00000000`00000001 00000000`02c4d640 00000000`00000020 : mscorwks!WKS::gc_heap::relocate_phase+0x5c

    00000642`7f4ebd24 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : mscorwks!WKS::gc_heap:Stick out tonguelan_phase+0x7e8

    00000642`7f4f1916 : 000321a3`9bf234bd 00000642`780976d0 ffffffff`00000000 00000000`00000000 : mscorwks!WKS::gc_heap::gc1+0x74

    00000642`7f5005e9 : 000321a3`9bf20385 00000008`00000000 00000000`ffffffff 00000000`002b3ea0 : mscorwks!WKS::gc_heap::garbage_collect+0x1a6

    00000642`7f51ea98 : 00000000`00000001 00000000`00000000 0000af43`2fc2de1a 00000642`7f46e58f : mscorwks!WKS::GCHeap::GarbageCollectGeneration+0x199

    00000642`7f51f05d : 00000000`002b3f08 00000000`002b3ea0 00000000`1b03eef8 00000000`02c4d660 : mscorwks!WKS::gc_heap::try_allocate_more_space+0x2e8

    00000642`7f51f434 : 00000642`74f5c440 00000000`02a46538 00000000`002b3f08 00000000`00287ca0 : mscorwks!WKS::GCHeap::Alloc+0x6d

    Unable to load image C:\WINDOWS\assembly\NativeImages_v2.0.50727_64\System\b5dd279b8fdf6866126da8cb9fa647ca\System.ni.dll, Win32 error 2

    *** WARNING: Unable to verify checksum for System.ni.dll

    00000642`7492c051 : 00000642`74f5c440 00000000`00000000 00000000`02a45a20 00000000`02a462e0 : mscorwks!JIT_NewFast+0x374

    00000642`7492c22e : 00000000`02a45a50 00000000`02a45a20 00000000`00000000 00000642`782a6553 : System_ni+0xac051

    00000642`749307a7 : 00000000`02c4a8d8 00000000`1b03f0f0 00000000`00000000 00000000`00000000 : System_ni+0xac22e

    00000642`80150b81 : 00000000`02a458f8 00000000`00000001 00000000`ffffffff 00000000`1b03f190 : System_ni+0xb07a7

    Unable to load image C:\WINDOWS\assembly\NativeImages_v2.0.50727_64\mscorlib\339a2c337cdafd47f2ba740bb03f9718\mscorlib.ni.dll, Win32 error 2

    *** WARNING: Unable to verify checksum for mscorlib.ni.dll

    00000642`780a9710 : 00000000`02a46060 00000000`02a46060 00000000`02a46108 00000000`1b03f4e0 : 0x642`80150b81

    00000642`780eeb2f : 00000000`1b03f4b0 00000000`1b03f6d8 00000000`77d40000 00000000`77ec0000 : mscorlib_ni+0xa9710

    00000642`7f67d4a2 : 00000000`02a46130 00000000`00000000 00000000`00000000 00000000`1b03f4e0 : mscorlib_ni+0xeeb2f

    00000642`7f5108f5 : 00000000`1b03f4e0 00000000`0000a33c 00000000`00262dd0 00000000`00000000 : mscorwks!CallDescrWorker+0x82

    00000642`7f522ff6 : 00000000`1b03f5d8 00000000`00000001 00000000`00000000 00000000`1b03f7d8 : mscorwks!CallDescrWorkerWithHandler+0xe5

    00000642`7f458e34 : 00000000`1b03fc10 00000000`1b03ff50 00000000`1b03fcb0 00000642`788f85f8 : mscorwks!MethodDesc::CallDescr+0x306

    00000642`7f498474 : ffffffff`00000001 00000000`002b3ea0 00000000`00000000 00000642`7f4f9e1e : mscorwks!ThreadNative::KickOffThread_Worker+0x190

    00000642`7f5ca069 : 00000000`00000000 00000000`00000000 00000000`002b3ea0 00000000`1b03fc10 : mscorwks!FusionBind::VerifyBindingStringW+0x78

    00000642`7f47297d : 00000000`00000000 00000000`002b3ea0 00000000`1b03fb50 00000000`1b03fbb0 : mscorwks!EEClass::FindPropertyMethod+0x175

    00000642`7f613ad5 : 00000000`1b03fc10 ffffffff`ffffffff 00000000`002b3ea0 00000000`002a4610 : mscorwks!MDInternalRW::GetMethodSpecProps+0xc9

    00000642`7f4524cb : 00000000`002b3ea0 00000000`00000000 00000000`00000000 00000000`00000007 : mscorwks!ShuffleThunkCache::CompileMLStub+0x351

    00000642`7f4545bc : 00000002`00000000 00000000`00000000 00000000`002b3ea0 00000000`1b03fcc8 : mscorwks!ThreadNative::KickOffThread+0xd3

    00000000`77d6b6da : 00000000`77d6b6a0 00000000`00000000 00000000`00000000 00000000`1b03ffa8 : mscorwks!Thread::intermediateThreadProc+0x78

    00000000`00000000 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : kernel32!BaseThreadStart+0x3a



    Wednesday, May 21, 2008 8:25 AM
  • The garbage collector is crashing while it is analyzing the thread's stack for live object references.  Could be a corrupted stack but that shouldn't happen when you use the managed SerialPort class.  You'll have to contact Microsoft CSS for support.
    • Marked as answer by nobugz Sunday, June 8, 2008 3:00 PM
    Wednesday, May 21, 2008 11:33 AM
  • I had a very similar error - my app would hang randomly and I was using the serial port.  I still don't know what caused the problem but I avoided it by setting the target platform to x86.  This is done by opening the .proj file for the solution and placing <PlatformTarget>x86</PlatformTarget> in.  For example:

    <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
        <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
        <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>

    I hope this helps.

    (Also, I was running on an x64 Vista machine with .NET 3.5 using System.IO.SerialPort as well as MySQL's .NET Connector and a bunch of other usual Windows forms stuff - if anyone has more information on the issues here it would be great to see something more useful posted).

    Furthermore, I am developing with Visual Studio Express 2008 which is why I had to configure the Platform Target parameter like this, and not just through an options dialogue which I think is available in the money version of MS VS.

    • Proposed as answer by iR4 Tuesday, June 17, 2008 10:26 AM
    • Edited by iR4 Tuesday, June 17, 2008 8:26 PM Options comment
    Tuesday, June 17, 2008 10:26 AM