I just discussed this issue with XVilka on IRC and wish to set the record for those finding this page by google
, and it seems the key here is that Printexc.get_backtrace () should be the first thing done in the exception handler. Exn.to_string clobbers this value.
Also a small correction: OCAMLRUNPARAM does work with native binaries, as long as they have been compiled with -g. Sometimes its scope may be affected by inlining, but in general it’s very useful.