From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p0ELFlwv020188 for ; Fri, 14 Jan 2011 22:15:47 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkwBAGdLME3RVda2kGdsb2JhbACcRwGICQgVAQECCQkMBxEEIKMMiXmCF4RQLoZSAQEDBYVKBIRrhis X-IronPort-AV: E=Sophos;i="4.60,324,1291590000"; d="scan'208";a="73098444" Received: from mail-iw0-f182.google.com ([209.85.214.182]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-MD5; 14 Jan 2011 22:15:41 +0100 Received: by mail-iw0-f182.google.com with SMTP id 39so3023374iwn.27 for ; Fri, 14 Jan 2011 13:15:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:from:date:message-id:subject:to :content-type; bh=zcpvE0aMWlOyN/85DZ4z5NytWl19ZYBL9YZZ20npA74=; b=XRW7TWLwfA2GhZPz8da1+PVk49OaJ8s1jr5zj+CxYZxSmlk3d7jzU2CZJXmt0+Y+2B f/0bgD4IyEB/hxU2oLikMH5DNYu49Zt6SYAeYZV11MsQlBAhMpUZKmC+Z9AzlDsQMK3q +2n2XQ7XfWbfFjnMWVzkjF7CUasPggV5PgH0U= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=wyKiDq35YgBbzwrV6y9JJCK6EV+R6pe9ocKZKYtR9oQvEYKfBlqpQBmZQ+Zf48XHwf 2JT3ZyRBpwYLNg89dk4r01kH4b/7i3EHCzp2OGEM/MvtnhCkn6v5m7QXB9lSyVtQ4ciJ fO4wGFGRQm7TY4uC7G7RRJwSrvotCDSf9W3ls= Received: by 10.231.11.131 with SMTP id t3mr1184799ibt.192.1295039741056; Fri, 14 Jan 2011 13:15:41 -0800 (PST) MIME-Version: 1.0 Received: by 10.231.14.10 with HTTP; Fri, 14 Jan 2011 13:15:15 -0800 (PST) From: Ashish Agarwal Date: Fri, 14 Jan 2011 16:15:15 -0500 Message-ID: To: Caml List Content-Type: multipart/alternative; boundary=00221532cebcbc59860499d4efca Subject: [Caml-list] printing an exception changes printed backtrace --00221532cebcbc59860499d4efca Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable I observe the following unexpected behavior: --- a.ml --- try =85 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 () =3D raise (Failure "") let g () =3D f () let _ =3D try g() with e -> (* Printf.eprintf "%s\n" (Printexc.to_string e); *) Printexc.print_backtrace stderr --00221532cebcbc59860499d4efca Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: quoted-printable I observe the following unexpected behavior:

--- a.ml ---
try
=A0=A0=85 some c= ode ...
with e ->
(* =A0Printf.eprintf "%s\n&qu= ot; (Printexc.to_string e); *)
=A0=A0Printexc.print_backtrace Legacy.stderr
------

Compiling as ocamlopt -g a.m= l gives:
$ ./a.out
Raised at file "fool.ml", line 162, characters 13-22
Called from file "bar.ml", lin= e 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 com= mented 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, cha= racters 19-28

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

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

--- b.ml ---
let f () =3D= raise (Failure "")
let g () =3D f ()
let _ =3D
=A0=A0try g()
=A0=A0with e ->
=A0=A0 =A0(* Printf.eprintf "%s\n"= (Printexc.to_string e); *)
=A0=A0 =A0Printexc.print_backtrace st= derr

--00221532cebcbc59860499d4efca--