Oops. Forgot about OCAMLRUNPARAM. Both your and my example work now. Okay, this resolves the issue in some sense; you have to be careful about exceptions being raised that you don't see. Thanks for the explanations.


On Mon, Jan 17, 2011 at 12:02 PM, Xavier Clerc <xavier.clerc@inria.fr> wrote:



De: "Ashish Agarwal" <agarwal1975@gmail.com>
À: "xclerc" <xavier.clerc@inria.fr>
Cc: "Caml List" <caml-list@inria.fr>
Envoyé: Lundi 17 Janvier 2011 17:41:13
Objet: Re: [Caml-list] printing an exception changes printed backtrace


On Mon, Jan 17, 2011 at 10:37 AM, xclerc <xavier.clerc@inria.fr> wrote:
 
The underlying problem is that "Printexc.print_backtrace" prints the backtrace
for the last exception raised... which can be one raised by "Printf.eprintf" or
"Printexc.to_string", but locally caught and not exposed to the outside world.

Okay, that makes sense. 

 
You will get different backtraces according to the value of "custom_printer".

I'm actually getting the same output (just "Not_found" printed). Tried native and byte code, on two different systems.

Based on your explanation, I was expecting the following to give different output if you change true to false. But actually nothing is printed out in any case. So I'm really unclear now as to what print_backtrace does.
Are you sure that you compiled the source with the "-g" option,
*and* set the OCAMLRUNPARAM environment variable to "b"?


Regards,

Xavier Clerc