From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id XAA12989; Fri, 27 Aug 2004 23:26:26 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id XAA14197 for ; Fri, 27 Aug 2004 23:26:25 +0200 (MET DST) Received: from plato.rocketdogcreative.com (plato.rocketdogcreative.com [66.139.78.99]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id i7RLQO4Z026788 for ; Fri, 27 Aug 2004 23:26:24 +0200 Received: from [10.0.1.3] (168-103-58-53.tcsn.qwest.net [168.103.58.53]) by plato.rocketdogcreative.com (8.11.6/8.11.6) with ESMTP id i7RLQNF27981 for ; Fri, 27 Aug 2004 14:26:24 -0700 Mime-Version: 1.0 (Apple Message framework v619) Content-Transfer-Encoding: 7bit Message-Id: Content-Type: text/plain; charset=US-ASCII; format=flowed To: caml-list@inria.fr From: David McClain Subject: [Caml-list] OCaml and C++ Throws Date: Fri, 27 Aug 2004 14:27:30 -0700 X-Mailer: Apple Mail (2.619) X-Miltered: at nez-perce with ID 412FA700.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; mcclain:01 mcclain:01 runtime:01 aborting:01 ocaml-c:01 runtime:01 intercept:01 generically:01 libs:01 wrappers:01 failwith:01 gcc:01 compiler:01 kernel:01 ocaml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I'm looking for any information on how to catch C++ derived throws from OCaml. Currently, these uncaught exceptions appear to trigger a SIGABRT (#6) that the runtime kernel appears to catch just so that it can print a message before aborting the application. I have tried numerous schemes to interpose some try-catch clauses in C++ between OCaml and the called C++ libraries. So far all attempts have failed. It appears that the try-catch mechanism is a "local" mechanism in the sense that if you try-catch around the direct library call down in C++ that works fine, but if you allow the exception to propagate upward through the original OCaml-C call then OCaml grabs control of these exceptions. Any higher up C++ try-catch clauses containing the OCaml code that calls into the C layer again are frustrated from ever seeing these thrown exceptions. OCaml appears to be converting these uncaught exceptions into signals that the runtime handles on behalf of the application. Any attempt to intercept these SIGABRT signals with my own handlers using module Sys appear to be ignored. Is there a way to generically handle C++ thrown exceptions? Having to know in advance which 3rd party libs will throw means also having to write explicit wrappers around each call to provide a catch clause for converting the messages into failwith() calls. These experiments have so far been performed on Mac OS X 10.3.5 using the Mac variants of the GCC compiler with OCaml 3.07. David McClain Senior Corporate Scientist Avisere, Inc. david.mcclain@avisere.com +1.520.390.7738 (USA) ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners