.NET mscorwks.dll crashes application (APPCRASH) with code c0000005

You might be unlucky to get hit with a very weird .NET application crash with about the following information:

Description:
Stopped working

Problem signature:
Problem Event Name:    APPCRASH
Application Name:    MJ12merger.exe
Application Version:    1.0.2687.33859
Application Timestamp:    4644ba87
Fault Module Name:    mscorwks.dll
Fault Module Version:    2.0.50727.128
Fault Module Timestamp:    45011d30
Exception Code:    c0000005
Exception Offset:    00000000001d7c4c
OS Version:    6.0.5728.2.0.0.274.3
Locale ID:    2057

App would die instantly, no exceptions to show where exactly it happened, very annoying if it happens at the end of very long processing. There seems to be very little information on the net as to why exactly this happens probably because most people won’t push framework as hard as we have to. ;)

The issue here is due to buffer overruns – if you use pointers in .NET code then you have to be very careful not to overwrite your memory buffers because otherwise you will destroy data used by .NET itself and this can result in rather weird failures that are not obviously due to your code: if you use unsafe code you need to assume the worst and be on guard at all times.

Naturally one can choose to use languages that do not support pointers at all, like say Java, but this is the choice of convenience that goes against goals of high performance: in my experience usage of pointers in a handful of tight places can double performance of the same C# code written without using pointers.

4 Responses to “.NET mscorwks.dll crashes application (APPCRASH) with code c0000005”

  1. ian Says:

    so what can i do to fix this problem, please in plain easy terms as i didnt understand what you wrote at all.what is .netand what do you mean pointers.

    thanks

  2. alexc Says:

    If you don’t know what pointers are then you are probably lucky not to need them and it is really the best approach with pointers – not to use them :)

    Pointers in .NET allow to bypass internal range checks that prevent reading or writing of data from/to memory that is not actually the memory that was allocated for a particular data structure. This means that in case of mistake you can write over some .NET data structures that will crash framework, or attempt to read from memory chunk that you are not allowed to read from – all this will lead to a crash of application.

  3. Anton Says:

    I’ve got exactly this error. I do not use pointers, but I do writing to SQLite db from time to time. Is it possible to overcome this issue in any way?

    Best regards,
    Anton.

  4. alexc Says:

    Not sure how Anton – something must be causing it. Try reinstalling .NET and make sure all .NET SPs are installed too.

    Also make sure you’ve got enough memory – looks like there is a problem in .NET 3.5 SP1 that will kill application dead if inside kernel it can’t allocate expected amount of memory, in this case message however is a bit different from that shown in this blog post.

Leave a Reply