Can Ada be told not to catch EXCEPTION_ACCESS_VIOLATION

0

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?

c++
windows
ada
gnat
asked on Stack Overflow Sep 13, 2018 by erict • edited Sep 13, 2018 by Neil Butterworth

1 Answer

0

You're actually asking a couple of different questions here:

  1. Q: What is the difference between a (Windows) 0xc0000005 access violation, and an Ada PROGRAM ERROR/EXCEPTION_ACCESS_VIOLATION?

  2. 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;
answered on Stack Overflow Sep 13, 2018 by paulsm4

User contributions licensed under CC BY-SA 3.0