From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.68.162.65 with SMTP id xy1mr1134849pbb.2.1382104407609; Fri, 18 Oct 2013 06:53:27 -0700 (PDT) X-Received: by 10.50.127.229 with SMTP id nj5mr55362igb.2.1382104407532; Fri, 18 Oct 2013 06:53:27 -0700 (PDT) Path: border1.nntp.dca3.giganews.com!backlog4.nntp.dca3.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!z6no54741784pbz.1!news-out.google.com!9ni50460qaf.0!nntp.google.com!o2no11534739qas.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 18 Oct 2013 06:53:27 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=137.100.97.30; posting-account=qIOakwoAAADak_AV0PLRbHCl6Q3GSm7V NNTP-Posting-Host: 137.100.97.30 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <269ef690-f594-4dda-b037-bf30e688dd2c@googlegroups.com> Subject: Exception handling in Ada -> C++ call? From: kevin.a.peterson@gmail.com Injection-Date: Fri, 18 Oct 2013 13:53:27 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Original-Bytes: 2575 Xref: number.nntp.dca.giganews.com comp.lang.ada:183656 Date: 2013-10-18T06:53:27-07:00 List-Id: 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 blo= ck. 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 #include 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 a= n instance of 'int'," which I expect, however the application doesn't actua= lly exit but spins a core to 100% usage until I kill it. Also interesting: = If I replace the try block with int x=3D5/0; and ignore the compiler warning, the application correctly crashes with SIG= FPE, however if I replace the try block with std::cout << "WHY" << std::endl; int x=3D5/0; I receive "terminate called without an active exception" and the applicatio= n hangs again until I kill it. Does anyone know the reason for this behavio= ur?=20 I'm currently using GNAT Pro 6.0.2 with GCC 4.1.2 and running on RHEL6, alt= hough I've also tried the same program on RHEL5 with earlier GNAT/GCC versi= ons and get the same results. I've also compiled 32 and 64 bit with no diff= erence. Thanks for the help