We have a large Ada/C++ system (using Gnatpro 7.3.2) running on Windows which very rarely crashes hard with a 0xC0000005 windows memory violation. I've tried to simplify by creating a small Ada program which calls a C++ library, and the library tries to write to address 0x07. But in this case, instead of getting the expected C0000005, the Ada subsystem reports a PROGRAM ERROR with the message EXCEPTION_ACCESS_VIOLATION and a nice stack trace.
Having to find this rare bug, I first wrote a C++ program writing to address 7, which caused a C000005 as expected, but this uses the MSVC runtime. My small Ada program shows different behaviour. Is it possible to disable the Ada runtime layer that catches the memory violation?
You're actually asking a couple of different questions here:
Q: What is the difference between a (Windows) 0xc0000005 access violation, and an Ada PROGRAM ERROR/EXCEPTION_ACCESS_VIOLATION?
Q: What can I do about it in my Ada application?
To better understand 0xc0000005, look here:
What exactly is the scope of Access Violation '0xc0000005'?
To deal with the Ada program error, why not just use a standard Ada "exception" block, for example:
with Ada.Exceptions; use Ada.Exceptions;
...
exception
when Error: EXCEPTION_ACCESS_VIOLATION =>
Put ("Access Violation: ");
Put_Line (Exception_Name (Error));
Put (Exception_Message (Error));
when Error: others =>
Put ("Something Else: ");
Put_Line (Exception_Information(Error));
end;
User contributions licensed under CC BY-SA 3.0