[delphi] What do I do when my program crashes with exception 0xc0000005 at address 0?

My Delphi program runs as an NT service and has been running fine for more than 2 months and then it stops suddenly and generates a crash dump:

Faulting application name: tca_shctisvc_ip.exe, version: 7.1.0.1843, time stamp: 0x2a425e19 Faulting module name: unknown, version: 0.0.0.0, time stamp: 0x00000000 Exception code: 0xc0000005 Fault offset: 0x00000000

There were no real addresses to work from based on information in the Windows event log. I was able to load the mini dump into WinDbg and it said there was an exception but found problems with the stack frames. A different tool (Viewminidump) was able to show me stacks of the running threads.

Where do I begin to resolve this issue?

This question is related to delphi debugging crash

The answer is


Exception code 0xc0000005 is an Access Violation. An AV at fault offset 0x00000000 means that something in your service's code is accessing a nil pointer. You will just have to debug the service while it is running to find out what it is accessing. If you cannot run it inside a debugger, then at least install a third-party exception logger framework, such as EurekaLog or MadExcept, to find out what your service was doing at the time of the AV.


Problems with the stack frames could indicate stack corruption (a truely horrible beast), optimisation, or mixing frameworks such as C/C++/C#/Delphi and other craziness as that - there is no absolute standard with respect to stack frames. (Some languages do not even have them!).

So, I suggest getting slightly annoyed with the stack frame issues, ignoring it, and then just use Remy's answer.


I was getting the same issue with a different application,

Faulting application name: javaw.exe, version: 8.0.51.16, time stamp: 0x55763d32
Faulting module name: mscorwks.dll, version: 2.0.50727.5485, time stamp: 0x53a11d6c
Exception code: 0xc0000005
Fault offset: 0x0000000000501090
Faulting process id: 0x2960
Faulting application start time: 0x01d0c39a93c695f2
Faulting application path: C:\Program Files\Java\jre1.8.0_51\bin\javaw.exe
Faulting module path:C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll

I was using the The Enhanced Mitigation Experience Toolkit (EMET) from Microsoft and I found by disabling the EMET features on javaw.exe in my case as this was the faulting application, it enabled my application to run successfully. Make sure you don't have any similar software with security protections on memory.


Examples related to delphi

What do I do when my program crashes with exception 0xc0000005 at address 0? Why does CreateProcess give error 193 (%1 is not a valid Win32 app) The application was unable to start correctly (0xc000007b) Indentation shortcuts in Visual Studio Split a string into an array of strings based on a delimiter How to track down access violation "at address 00000000" Is there a program to decompile Delphi? How do I include a newline character in a string in Delphi?

Examples related to debugging

How do I enable logging for Spring Security? How to run or debug php on Visual Studio Code (VSCode) How do you debug React Native? How do I debug "Error: spawn ENOENT" on node.js? How can I inspect the file system of a failed `docker build`? Swift: print() vs println() vs NSLog() JavaScript console.log causes error: "Synchronous XMLHttpRequest on the main thread is deprecated..." How to debug Spring Boot application with Eclipse? Unfortunately MyApp has stopped. How can I solve this? 500 internal server error, how to debug

Examples related to crash

Android Room - simple select query - Cannot access database on the main thread Node.js heap out of memory iOS app with framework crashed on device, dyld: Library not loaded, Xcode 6 Beta Android Studio - How to increase Allocated Heap Size Exception Error c0000005 in VC++ What do I do when my program crashes with exception 0xc0000005 at address 0? Can anybody tell me details about hs_err_pid.log file generated when Tomcat crashes? Login with facebook android sdk app crash API 4 C# : "A first chance exception of type 'System.InvalidOperationException'" How to get Android crash logs?