none
CLR20r3 Exception from mscorlib RRS feed

  • Question

  • Hi All,

    We developed an application in .Net 3.5 SP1. When we are running this application in a Win 7 SP1 machine, the application is getting terminated occationally with following error

    <application> has stopped working

    The event log leads to a file and the information in the file is showing below details.

    Version=1
    EventType=CLR20r3
    EventTime=129701353576088636
    ReportType=2
    Consent=1
    UploadTime=129701353577788619
    ReportIdentifier=e0746dbc-36a4-11e1-9adc-0024e83ac378
    Response.type=4
    Sig[0].Name=Problem Signature 01
    Sig[0].Value=JW0UVQM3PNICSJO3BY4QOQA1NWSUVD4B
    Sig[1].Name=Problem Signature 02
    Sig[1].Value=1.6.0.4
    Sig[2].Name=Problem Signature 03
    Sig[2].Value=4efc69ec
    Sig[3].Name=Problem Signature 04
    Sig[3].Value=mscorlib
    Sig[4].Name=Problem Signature 05
    Sig[4].Value=2.0.0.0
    Sig[5].Name=Problem Signature 06
    Sig[5].Value=4e1539fa
    Sig[6].Name=Problem Signature 07
    Sig[6].Value=3aeb
    Sig[7].Name=Problem Signature 08
    Sig[7].Value=37
    Sig[8].Name=Problem Signature 09
    Sig[8].Value=Exception
    DynamicSig[1].Name=OS Version
    DynamicSig[1].Value=6.1.7601.2.1.0.256.4
    DynamicSig[2].Name=Locale ID
    DynamicSig[2].Value=3081
    UI[2]=<<Exe name>>
    UI[3]=<<application>> has stopped working
    UI[4]=Windows can check online for a solution to the problem.
    UI[5]=Check online for a solution and close the program
    UI[6]=Check online for a solution later and close the program
    UI[7]=Close the program
    LoadedModule[0]=.................

    ............

    State[0].Key=Transport.DoneStage1
    State[0].Value=1
    FriendlyEventName=Stopped working
    ConsentKey=CLR20r3
    AppName=Shell
    AppPath=<<application exe name with path>>
    ReportDescription=Stopped working

    This is happening only on Win 7 SP1 machines. Can somebody guide me on how to fix this defect?

    Regards,

    Abhilash

     

     

     

    Wednesday, January 11, 2012 3:25 AM

All replies

  • To catch unhandled exception, you can subscribe to System.Windows.Forms.Application.ThreadException in your Main() function, before calling Application.Run() method.

    static class Program
    {
        [STAThread]
        static void Main()
        {
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
    
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
    
        }
    
        static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            MessageBox.Show(e.Exception.Message);
            Application.Exit();
        }
    }
    


    Note: The above code may not catch unhandled exception when you are debugging in Visual Studio, because VS may break the code at the point where exception has occured. So, Run your executable by doule clicking it.


    Please mark this post as answer if it solved your problem. Happy Programming!
    Wednesday, January 11, 2012 5:51 AM
  • Hi Adavesh,

    We have handlers for both Application.ThreadException and Application.CurrentDomain.UnhandledException and the SetUnhandledExceptionMode also set as mentioned , but both not getting hit when this exception is happening.  We have some WPF controls hosted in ElementHost also in the application. We can consistently reproduce the issue be opening different forms contains WPF controls. But at times the application crashing even without opening the forms contains WPF controls.

    Regards,

    Abhilash

    Thursday, January 12, 2012 3:07 AM
  • You didn't say yours is WPF application. Form WPF applications you need to subscribe to System.Windows.Application.DispatcherUnhandledException. Visit below links to know how to use it.

    http://msdn.microsoft.com/en-us/library/system.windows.application.dispatcherunhandledexception(v=vs.110).aspx

    http://www.codeproject.com/Articles/90866/Unhandled-Exception-Handler-For-WPF-Applications


    Please mark this post as answer if it solved your problem. Happy Programming!
    Thursday, January 12, 2012 5:39 AM
  • Sorry for the confusion. My application is a normal windows application with some forms are using WPF richtextboxes hosted using ElementHost. I added the below handler also for WPF exceptions and tried.

    Application.Current.DispatcherUnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(Application_DispatcherUnhandledException);

    But its not hitting this handler also.

    regards,

    Abhilash 

    Thursday, January 12, 2012 6:27 AM
  • Hmmm... Then I think you have also tried using System.AppDomain’s UnhandledException event as well.

    The last option before you add more debug log to your application is to try/catch block aroung your Application.Run call in Main function.

    static void Main()
    {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
           
            try 
            {
                    Application.Run(new MainForm());
            }
            catch(Exception excep)  //you can put a breakpoint here
            {      
                    MessageBox.Show(excep.Message);
            }
    }
    

    If this also doesn't work, I think the issue is related to memory. I suggest you to use tools like WinDbg or Debug Diagnostic tools to investigate the issue.


    Please mark this post as answer if it solved your problem. Happy Programming!
    Thursday, January 12, 2012 6:46 AM
  • Thanks for reply Adavesh.

    We got the crash dump from the machine and which has the information posted at the end. It look like the application is throwing an exception and is getting handled in the exception handler (handle one of Application.CurrentDomain.UnhandledException or ThreadException). But when the exception handler is trying to display a message using a message box, a System.Security.SecurityException is raised with System.Security.Permissions.UIPermission is not available. There is no details on what exception is thrown initially. 

    I tested the exception block with raising an exception through code and allow it handle in the exception handler code, the message is properly displayed. 

    So the application had all the necessary permissions before the first exception, but after the exception those permissions got revoked.   This issue now blocking our app to get promoted to Win 7 environment.

    I am not sure why the framework is not adding a detailed exception log anywhere to analyse these kind of Clr exceptions.

    FAULTING_IP:
    +73a0300
    00000000`00000000 ??              ???

    EXCEPTION_RECORD:  0000000000214650 -- (.exr 0x214650)
    ExceptionAddress: 000007fefdb0cacd (KERNELBASE!RaiseException+0x000000000000003d)
       ExceptionCode: e0434f4d (CLR exception)
      ExceptionFlags: 00000001
    NumberParameters: 1
       Parameter[0]: ffffffff8013150a

    FAULTING_THREAD:  0000000000000e7c

    DEFAULT_BUCKET_ID:  CLR_EXCEPTION

    PROCESS_NAME:  <<Exe Name>>

    ERROR_CODE: (NTSTATUS) 0x80000003 - {EXCEPTION}  Breakpoint  A breakpoint has been reached.

    EXCEPTION_CODE: (HRESULT) 0x80000003 (2147483651) - One or more arguments are invalid

    MOD_LIST: <ANALYSIS/>

    NTGLOBALFLAG:  0

    APPLICATION_VERIFIER_FLAGS:  0

    MANAGED_STACK: !dumpstack -EE
    OS Thread Id: 0xe7c (0)
    Child-SP         RetAddr          Call Site

    EXCEPTION_OBJECT: !pe 4eec150
    Exception object: 0000000004eec150
    Exception type: System.Security.SecurityException
    Message: Request for the permission of type 'System.Security.Permissions.UIPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
    InnerException: <none>
    StackTrace (generated):
    <none>
    StackTraceString: <none>
    HResult: 8013150a

    MANAGED_OBJECT: !dumpobj 4eed5c0
    Name: System.String
    MethodTable: 000007fef04c7b08
    EEClass: 000007fef00ce550
    Size: 3464(0xd88) bytes
     (C:\Windows\assembly\GAC_64\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll)
    String:    at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed)
       at System.Security.CodeAccessSecurityEngine.CheckHelper(PermissionSet grantedSet, PermissionSet refusedSet, CodeAccessPermission demand, PermissionToken permToken, RuntimeMethodHandle rmh, Object assemblyOrString, SecurityAction action, Boolean throwException)
       at System.Security.CodeAccessSecurityEngine.CheckHelper(CompressedStack cs, PermissionSet grantedSet, PermissionSet refusedSet, CodeAccessPermission demand, PermissionToken permToken, RuntimeMethodHandle rmh, Assembly asm, SecurityAction action)
       at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
       at System.Security.CodeAccessPermission.Demand()
       at System.Windows.Forms.MessageBox.ShowCore(IWin32Window owner, String text, String caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, Boolean showHelp)
       at System.Windows.Forms.MessageBox.Show(String text, String caption, MessageBoxButtons buttons, MessageBoxIcon icon)
       at <<appnamespace>>.UI.CmspMessageBox.Show(String messageId, String[] parameters)
       at <<appnamespace>>.ShellApplication.HandleException(Exception ex)
       at System.Windows.Forms.Application.ThreadContext.OnThreadException(Exception t)
       at System.Windows.Forms.Control.WndProcException(Exception e)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

    Fields:
                  MT    Field   Offset                 Type VT     Attr            Value Name
    000007fef04ced78  4000096        8         System.Int32  1 instance             1720 m_arrayLength
    000007fef04ced78  4000097        c         System.Int32  1 instance             1719 m_stringLength
    000007fef04c9550  4000098       10          System.Char  1 instance               20 m_firstChar
    000007fef04c7b08  4000099       20        System.String  0   shared           static Empty
                                     >> Domain:Value Unable to get AppDomain 453930
    000007fef04c9400  400009a       28        System.Char[]  0   shared           static WhitespaceChars
                                     >> Domain:Value Unable to get AppDomain 453930

    EXCEPTION_MESSAGE:  Request for the permission of type 'System.Security.Permissions.UIPermission, mscorlib, Version=2.0

    MANAGED_OBJECT_NAME:  System.Security.SecurityException

    CONTEXT:  0000000000214020 -- (.cxr 0x214020)
    rax=0000000077cf1079 rbx=0000000000000055 rcx=0000000000214020
    rdx=00000000000000e0 rsi=0000000000214750 rdi=000000000045c4b0
    rip=000007fefdb0cacd rsp=0000000000214630 rbp=0000000000214d20
     r8=0000000000000000  r9=0000000000000000 r10=0000000000000038
    r11=0000000000214670 r12=00000000e0434f4d r13=ffffffff8013150a
    r14=0000000000000001 r15=0000000000000001
    iopl=0         nv up ei pl nz na pe nc
    cs=0033  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00000202
    KERNELBASE!RaiseException+0x3d:
    000007fe`fdb0cacd 4881c4c8000000  add     rsp,0C8h
    Resetting default scope

    PRIMARY_PROBLEM_CLASS:  CLR_EXCEPTION

    BUGCHECK_STR:  APPLICATION_FAULT_CLR_EXCEPTION

    LAST_CONTROL_TRANSFER:  from 000007fef113923f to 000007fefdb0cacd

    STACK_TEXT: 
    00000000`00214630 000007fe`f113923f : 00000000`0045c4b0 00000000`00000055 00000000`00214750 00000000`0045c4b0 : KERNELBASE!RaiseException+0x3d
    00000000`00214700 000007fe`f14d5e67 : 00000000`050f0308 00000000`00000000 000007fe`00000000 000007fe`00000001 : mscorwks!StrongNameFreeBuffer+0x53a3
    00000000`002147f0 000007fe`f14d7fc6 : 00002026`00000001 00000000`00000000 0000d193`2559433e 00000000`00000000 : mscorwks!Ordinal24+0xb977
    00000000`00214820 000007fe`f155b0b5 : 00000000`00000055 00000000`00214d20 00000000`00000015 00000000`00000000 : mscorwks!Ordinal24+0xdad6
    00000000`00214850 000007fe`f155b0cb : 00000000`04eec150 00000000`00000000 00000000`00000000 00000000`00000000 : mscorwks!StrongNameSignatureVerificationEx+0x2fb5
    00000000`002148c0 000007fe`f157b936 : 00000000`00214a40 00000000`002155e8 00000000`00000003 00000000`00000000 : mscorwks!StrongNameSignatureVerificationEx+0x2fcb
    00000000`002148f0 000007fe`f141f4e8 : 00000000`00453930 00000000`00214d20 00000000`00000000 00000000`00a207f0 : mscorwks!GetRuntimeStackWalkInfo+0x73c6
    00000000`00214b00 000007fe`f120bdd4 : 00000000`00000001 00000000`0045c401 00000000`258745b0 00000000`00a207f0 : mscorwks!CertCreateAuthenticodeLicense+0x1eb7d8
    00000000`00214c70 000007fe`f122e2b6 : 00000000`002155e8 00000000`0045c4b0 00000000`00000000 00000000`00000000 : mscorwks!CreateAssemblyCache+0xabc
    00000000`00214d00 00000000`77a19bd1 : 00000000`00130624 00000000`0000000f 00000000`00000000 00000000`00000000 : mscorwks!IEE+0xb736
    00000000`00214d90 00000000`77a172cb : 00000000`00000000 00000000`00a2081c 00000000`00000000 00000000`00000000 : user32!UserCallWinProcCheckWow+0x1ad
    00000000`00214e50 00000000`77a16829 : 00000000`00000003 00000000`000003e0 00000000`00215140 000007fe`ff45ffa2 : user32!DispatchClientMessage+0xc3
    00000000`00214eb0 00000000`77b51225 : 00000000`00000003 00000000`003e0008 00000000`00000003 00000000`00000086 : user32!_fnDWORD+0x2d
    00000000`00214f10 00000000`00000003 : 00000000`003e0008 00000000`00000003 00000000`00000086 00000000`00214f68 : ntdll!KiUserCallbackDispatcherContinue
    00000000`00214f18 00000000`003e0008 : 00000000`00000003 00000000`00000086 00000000`00214f68 00000002`00000030 : 0x3
    00000000`00214f20 00000000`00000003 : 00000000`00000086 00000000`00214f68 00000002`00000030 00000000`77a16e5a : 0x3e0008
    00000000`00214f28 00000000`00000086 : 00000000`00214f68 00000002`00000030 00000000`77a16e5a 00000000`00215140 : 0x3
    00000000`00214f30 00000000`00214f68 : 00000002`00000030 00000000`77a16e5a 00000000`00215140 00000000`00000000 : 0x86
    00000000`00214f38 00000002`00000030 : 00000000`77a16e5a 00000000`00215140 00000000`00000000 00000000`00214f98 : 0x214f68
    00000000`00214f40 00000000`77a16e5a : 00000000`00215140 00000000`00000000 00000000`00214f98 00000000`00000000 : 0x2`00000030
    00000000`00214f48 00000000`00215140 : 00000000`00000000 00000000`00214f98 00000000`00000000 00000000`01033a20 : user32!ZwUserDispatchMessage+0xa
    00000000`00214f50 00000000`00000000 : 00000000`00214f98 00000000`00000000 00000000`01033a20 00000000`0000000f : 0x215140


    FOLLOWUP_IP:
    mscorwks!StrongNameFreeBuffer+53a3
    000007fe`f113923f 90              nop

    SYMBOL_STACK_INDEX:  1

    SYMBOL_NAME:  mscorwks!StrongNameFreeBuffer+53a3

    FOLLOWUP_NAME:  MachineOwner

    MODULE_NAME: mscorwks

    IMAGE_NAME:  mscorwks.dll

    DEBUG_FLR_IMAGE_TIMESTAMP:  4e153960

    STACK_COMMAND:  .cxr 0x214020 ; kb

    FAILURE_BUCKET_ID:  CLR_EXCEPTION_80000003_mscorwks.dll!StrongNameFreeBuffer

    BUCKET_ID:  X64_APPLICATION_FAULT_CLR_EXCEPTION_mscorwks!StrongNameFreeBuffer+53a3

    Followup: MachineOwner
    ---------

     


    • Edited by Abhilash KC Monday, January 16, 2012 12:57 AM
    Friday, January 13, 2012 7:13 AM
  • I added following code in the program. Can some body guide on how to set up sufficient permissions in Windows 7.

    [System.Security.Permissions.

    PermissionSet(System.Security.Permissions.SecurityAction.Assert, Unrestricted = true)]

    The application is not crashing now.  I got the following information from the exception 

    System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.UIPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
       at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed)
       at System.Security.CodeAccessSecurityEngine.CheckHelper(PermissionSet grantedSet, PermissionSet refusedSet, CodeAccessPermission demand, PermissionToken permToken, RuntimeMethodHandle rmh, Object assemblyOrString, SecurityAction action, Boolean throwException)
       at System.Security.CodeAccessSecurityEngine.CheckHelper(CompressedStack cs, PermissionSet grantedSet, PermissionSet refusedSet, CodeAccessPermission demand, PermissionToken permToken, RuntimeMethodHandle rmh, Assembly asm, SecurityAction action)
       at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
       at System.Security.CodeAccessPermission.Demand()
       at System.Windows.Forms.Control.get_Parent()

    The action that failed was:

    Demand

    The type of the first permission that failed was:

    System.Security.Permissions.UIPermission

    The first permission that failed was:

    <IPermission class="System.Security.Permissions.UIPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"

    version="1"

    Window="AllWindows"/>

    The demand was for:

    <IPermission class="System.Security.Permissions.UIPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"

    version="1"

    Window="AllWindows"/>

     The granted set of the failing assembly was:

    <PermissionSet class="System.Security.NamedPermissionSet"

    version="1" Name="__WebProxySandbox">

    <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"

    version="1"

    Flags="Execution"/>

    </PermissionSet>

    The assembly or AppDomain that failed was:

     

    mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

     

     


    • Edited by Abhilash KC Monday, January 16, 2012 11:35 PM
    Monday, January 16, 2012 10:27 AM