我们有一个在Windows上运行的大型Ada / C ++系统(使用Gnatpro 7.3.2),很少因严重违反0xC0000005而导致内存崩溃。我试图通过创建一个调用C ++库的小型Ada程序来简化,并且库试图写入地址0x07。但在这种情况下,Ada子系统不会获得预期的C0000005,而是使用消息EXCEPTION_ACCESS_VIOLATION和一个很好的堆栈跟踪来报告PROGRAM ERROR。
必须找到这个罕见的错误,我首先编写了一个写入地址7的C ++程序,它导致了C000005的预期,但这使用了MSVC运行时。我的小Ada程序表现出不同的行为。是否可以禁用捕获内存冲突的Ada运行时层?
你实际上在这里问了几个不同的问题:
为了更好地理解0xc0000005,请看这里:
What exactly is the scope of Access Violation '0xc0000005'?
要处理Ada程序错误,为什么不使用标准的Ada“异常”块,例如:
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;