Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: David McClain <David.McClain@Avisere.com>
To: caml-list@inria.fr
Subject: [Caml-list] OCaml and C++ Throws
Date: Fri, 27 Aug 2004 14:27:30 -0700	[thread overview]
Message-ID: <E6BDD882-F86F-11D8-9FED-000A95C19BAA@Avisere.com> (raw)

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


                 reply	other threads:[~2004-08-27 21:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E6BDD882-F86F-11D8-9FED-000A95C19BAA@Avisere.com \
    --to=david.mcclain@avisere.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox