From: kevin.a.peterson@gmail.com
Subject: Exception handling in Ada -> C++ call?
Date: Fri, 18 Oct 2013 06:53:27 -0700 (PDT)
Date: 2013-10-18T06:53:27-07:00 [thread overview]
Message-ID: <269ef690-f594-4dda-b037-bf30e688dd2c@googlegroups.com> (raw)
Hi, I'm having problems with an Ada program I've been working on. This Ada program makes a call to a C++ library, and the C++ call has a try/catch block. I think my problem boils down to uncaught exceptions hanging on the c++ side hanging the program. This code demonstrates the issue:
Ex.C:
#include <stdexcept>
#include <iostream>
extern "C"
void tester(){
try{
throw 1;
}
catch(std::logic_error e){
}
};
testada.adb:
with Ada.Text_Io;
procedure testada is
procedure TestCpp;
pragma import(C,TestCpp,"tester");
begin
Ada.Text_Io.Put_Line("Calling TestCpp");
TestCpp;
end testada;
When I build this and run testada, I get "terminate called after throwing an instance of 'int'," which I expect, however the application doesn't actually exit but spins a core to 100% usage until I kill it. Also interesting: If I replace the try block with
int x=5/0;
and ignore the compiler warning, the application correctly crashes with SIGFPE, however if I replace the try block with
std::cout << "WHY" << std::endl;
int x=5/0;
I receive "terminate called without an active exception" and the application hangs again until I kill it. Does anyone know the reason for this behaviour?
I'm currently using GNAT Pro 6.0.2 with GCC 4.1.2 and running on RHEL6, although I've also tried the same program on RHEL5 with earlier GNAT/GCC versions and get the same results. I've also compiled 32 and 64 bit with no difference.
Thanks for the help
next reply other threads:[~2013-10-18 13:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-18 13:53 kevin.a.peterson [this message]
2013-10-18 14:46 ` Exception handling in Ada -> C++ call? Simon Wright
2013-10-21 7:58 ` Egil H H
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox