caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] printing an exception changes printed backtrace
@ 2011-01-14 21:15 Ashish Agarwal
  2011-01-14 21:59 ` Daniel Bünzli
  2011-01-17 15:37 ` xclerc
  0 siblings, 2 replies; 7+ messages in thread
From: Ashish Agarwal @ 2011-01-14 21:15 UTC (permalink / raw)
  To: Caml List

[-- Attachment #1: Type: text/plain, Size: 1064 bytes --]

I observe the following unexpected behavior:

--- a.ml ---
try
  … some code ...
with e ->
(*  Printf.eprintf "%s\n" (Printexc.to_string e); *)
  Printexc.print_backtrace Legacy.stderr
------

Compiling as ocamlopt -g a.ml gives:
$ ./a.out
Raised at file "fool.ml", line 162, characters 13-22
Called from file "bar.ml", line 13, characters 5-56
Called from file "bar.ml", line 43, characters 4-63

Now this doesn't say which exception was raised, so I uncomment the
commented line. I'm expecting the identical output, but with the exception
printed first. However, I get:

$ ./a.out
Not_found
Raised at file "hashtbl.ml", line 93, characters 19-28

So it appears that printing an exception changes the backtrace. Is that
possible?

Unfortunately, I cannot reproduce this behavior in a minimal example. The
following script behaves as expected:

--- b.ml ---
let f () = raise (Failure "")
let g () = f ()
let _ =
  try g()
  with e ->
    (* Printf.eprintf "%s\n" (Printexc.to_string e); *)
    Printexc.print_backtrace stderr

[-- Attachment #2: Type: text/html, Size: 1736 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-01-17 17:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-14 21:15 [Caml-list] printing an exception changes printed backtrace Ashish Agarwal
2011-01-14 21:59 ` Daniel Bünzli
2011-01-14 22:05   ` Ashish Agarwal
2011-01-17 15:37 ` xclerc
2011-01-17 16:41   ` Ashish Agarwal
2011-01-17 17:02     ` Xavier Clerc
2011-01-17 17:12       ` Ashish Agarwal

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).