caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] OCaml and C++ Throws
@ 2004-08-27 21:27 David McClain
  0 siblings, 0 replies; only message in thread
From: David McClain @ 2004-08-27 21:27 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-08-27 21:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-27 21:27 [Caml-list] OCaml and C++ Throws David McClain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).