Welcome to MSDN Blogs Sign in | Join | Help

What is a C0000005 crash?

 

In my blog about Dr. Watson I talked about product crashes. What is an example of a crash? How destructive is it?

 

Here’s a simple example. MyFunction takes a string parameter and calculates its length

 

MyFunction (char * StringParam) {

         

          int nlen;        // declare an integer variable

          nlen = strlen(StringParam);

          <more code>

 

}

 

 

Doesn’t look like there’s a bug does it?

 

But there’s a potential bug: the strlen function in the C Standard Library counts the bytes in the string before finding a zero (null) byte. If the string does not have a null byte, then the strlen function will be accessing memory beyond the string buffer looking for a null byte.

 

This is called a Buffer Overrun error. If the memory accessed beyond the string is not allocated to the process, then a C0000005 exception (Access Violation) will result. If this exception is unhandled by the process, then the ‘unhandled exception handler” of the OS will be invoked. This is typically Dr. Watson. (However, the memory may be legitimately accessed, but may be overwritten by a virus that takes advantage of a buffer overrun on a strcpy Standard Library function).

 

If you have Visual Studio installed, you can look at the file PlatformSDK\include\ntstatus.h to find some of the various kinds of exceptions:

 

// MessageId: STATUS_ACCESS_VIOLATION

//

// MessageText:

//

//  The instruction at "0x%08lx" referenced memory at "0x%08lx". The memory could not be "%s".

//

#define STATUS_ACCESS_VIOLATION          ((NTSTATUS)0xC0000005L)    // winnt

 

 

 

In the old days of Win3.11, there was no memory protection enforcement: Accessing any memory in the process address space was fair game.  strlen would just cruise merrily through the process memory, even through non-owned memory, until it found a null byte. Thus, old code may run fine on old OS’s, but when run on a new OS, it might crash.

 

The C Standard Library (also known as the runtime library) is not part of the C language, but it is assumed by all C development environments (particularly the linker) to be available. Microsoft’s versions have “MSVCRT” in their names. When the string functions were defined, the strings were assumed to be character arrays with a terminating null byte. This implies possible buffer overruns, as well as that no strings can have embedded nulls (like binary data).

 

The C++ language has just as much accessibility to the C Standard library, although string classes and objects can be used. Thus buffer overruns are still around. Most processes that run on your computer today are primarily written in C or C++.

 

Using managed code in .NET, a string is an object that has a length property. No null terminating byte is assumed.

 

What are the consequences of a crash? If it occurs in a User mode application, then that process is no longer running, but all other running processes on the machine are still valid. If it occurs in a kernel mode application, such as a device driver, all bets are off because the erroneous code had much higher access rights to the machine than a user mode program.

Except for video driver crashes, I haven’t rebooted my machines in years due to a crash.

 

Most of the security bulletins and Windows Updates are due to buffer overruns. If the standard library had been defined to pass in a maximum length parameter along with every string buffer, many of these security patches would never exist.

Published Wednesday, June 30, 2004 4:36 PM by Calvin_Hsia

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: What is a C0000005 crash?

Wednesday, June 30, 2004 11:51 PM by josh
std::string doesn't use a terminating nul, unless you're converting it from/to a C string. But you can't really pass std::strings between binaries compiled with different compilers, or even linked against different instances of the runtime library.

# re: What is a C0000005 crash?

Thursday, July 01, 2004 2:49 AM by John
So, managed code in .NET will not crash easily?

# re: What is a C0000005 crash?

Friday, July 08, 2005 1:51 AM by Manju Rachel George
We got " C0000005 crash " error while doing an SNMP Walk for a device.We are looking for fixing it in our product.This document proved to be very vital.

# re: What is a C0000005 crash?

Tuesday, July 18, 2006 12:45 AM by ashok
what is solution for this crach.is it depends on the application progrme or on OS?.Because we got same access violation in STS of APG40.if we need i send core dump

# re: What is a C0000005 crash?

Tuesday, July 18, 2006 1:38 AM by ashok
what change we should make in the above code to remove the bug.
solution for the bug

# Analyzing Blog hit statistics

Thursday, July 20, 2006 12:52 PM by Calvin Hsia's WebLog
It takes a lot of work to create the blog posts and code samples that I put in my blog, and I was curious...

# re: What is a C0000005 crash?

Tuesday, December 05, 2006 1:55 PM by BClark

We are on VFP9 SP1 and we seem to be getting this when I call The LEFT( function ie., LEFT(string,6).

This has happened twice so far this week, in different locations in our code.  Once in form code, and once in report code.

Does anyone have any further solution to this?

Thanks in advance...

# re: What is a C0000005 crash?

Tuesday, January 16, 2007 2:23 PM by Claude

We are getting this error consistantly using reports created by fp2.5b for dos under vfp9 sp1. even after converting the reports to a windows version, sp1 still gets errors but i think there gone in the sp2 beta. havent proven this yet.

i have also found that while running the older report files, the memory handles returned by sys(1011) keeps climbing till we get the dreaded c5 error.

help!!!!

# re: What is a C0000005 crash?

Thursday, April 05, 2007 4:24 AM by Amit

What cause it to crash at OS level

# re: What is a C0000005 crash?

Sunday, April 15, 2007 6:31 AM by #

This is happening 90% of the time i'm afront the computer, help!!

# re: What is a C0000005 crash?

Monday, April 23, 2007 5:13 AM by Lingarao

Frequently, We are getting access voilation problem on Windows NT environment while using Oracle Forms .

 How to over come from this problem ?.

 Please help me.

# re: What is a C0000005 crash?

Wednesday, May 02, 2007 8:17 AM by Sandeep Garg

I am also facing this exception during inserting test cases in Rational Test Manager.

Can you please help me how to come out of this crash and resolve the same....

# re: What is a C0000005 crash?

Wednesday, May 02, 2007 8:17 AM by Sandeep Garg

I am also facing this exception during inserting test cases in Rational Test Manager.

Can you please help me how to come out of this crash and resolve the same....

# re: What is a C0000005 crash?

Wednesday, June 13, 2007 8:34 PM by Bob

How many of you with this error are using Core 2 duo and didn't have this error before upgrading to this processor?

# re: What is a C0000005 crash?

Tuesday, July 24, 2007 4:20 PM by Needhelp

Can anyone help pls:

The application, N:\Program Files\FM\FM.exe, generated an application error The error occurred on 07/24/2007 @ 16:11:05.529 The exception generated was c0000005 at address 2787A62C (ssdw3b32!DllUnregisterServer)

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

# re: What is a C0000005 crash?

Tuesday, July 24, 2007 4:23 PM by Needhelp

Can anyone help pls:

I recently updated the server from old NT to Win2k3 server with new hardware and yes Intel Dual Cores.

The application, N:\Program Files\FM\FM.exe, generated an application error The error occurred on 07/24/2007 @ 16:11:05.529 The exception generated was c0000005 at address 2787A62C (ssdw3b32!DllUnregisterServer)

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

# re: What is a C0000005 crash?

Sunday, August 12, 2007 3:19 PM by Stallion

{quote}

Wednesday, June 13, 2007 8:34 PM by Bob

How many of you with this error are using Core 2 duo and didn't have this error before upgrading to this processor?

{/quote}

I have a notebook using core 2 duo and I'm getting this error every time.... I' fed up with this :(

Does anyone know the solution on this problem????

# re: What is a C0000005 crash?

Tuesday, August 21, 2007 5:46 AM by shark

I have the same exception, Core 2 Duo.

Exception was generated during GetModuleFileName calling, strange situation :(

# Customer question: what does the crash call stack mean

Thursday, September 27, 2007 9:19 PM by Calvin Hsia's WebLog

A customer asks: I read your article "Intentionally crash your program". I have some questions that I

# re: What is a C0000005 crash?

Monday, October 08, 2007 9:19 AM by Kev

I had the same problem after making a simple change to an Oracle Forms application.  The only way I could solve it was to revert back to a previous version of the source code then make the change again.  It's been fine ever since then.

# re: What is a C0000005 crash?

Monday, October 22, 2007 8:16 AM by Babak Bandpey

Running on VM-Ware, blade servers + Core 2 duo,  Win 2003 Server. I'm receiving sporadic occurrences of this error and it has made me sleepless. Just to let you know.

Sincerely

# re: What is a C0000005 crash?

Sunday, December 09, 2007 6:17 PM by Term1nUS

Well, I've got this exception starting Skype. And what is ineteresting... When Skype started it want to get my ID, pass and then windows says @Exception c0000005

Windows Server 2008 Datacenter Full

# re: What is a C0000005 crash?

Monday, January 14, 2008 2:31 PM by Kevin Bentley

I get this error when I deploy Oracle 10g via SMS and it seems to be related to the directory structure like mentioned above.  I wish I could find a solution because moving this entire package to a different directory (higher) will suck do to its size.  Anyone have any creative solutions?

# re: What is a C0000005 crash?

Thursday, January 24, 2008 10:45 AM by Mohd Farid

My MS SQL 2000 crashed with c0000005 exception EVERYTIME defragging indexes is done. Arrrgghhhh.......

# re: What is a C0000005 crash?

Thursday, February 14, 2008 7:00 AM by Emerson Prado

I get this error with Trendnet TEW-228PI (Realtek RTL8180 chipset) and its software (Wireless Configuration Utility), under Win2k SP4. However, the computer doesn't stop. I only get a window saying the app made an illegal operation and will be closed. I found the error code in Event Viewer. It has something to do with the driver. I'll search some more, as I've seen this board working in this OS before.

Best regards

# re: What is a C0000005 crash?

Saturday, May 17, 2008 4:25 PM by Halo Modder

I get this error when I modified the plasma pistol on Halo 1.04. I tried to prevent it from happening by putting the settings of the weapon back to its original. It doesnt work. Is there another way to reverse it otherthan creating a new user account?

Leave a Comment

(required) 
required 
(required) 
 
Page view tracker