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-- From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p0ELxbir021338 for ; Fri, 14 Jan 2011 22:59:37 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AiEBAGpWME3RVdI2kGdsb2JhbACECqBHCBUBAQIJCQwHEQQgoxuJPYJThEqHAAEBAwWBH4M3dASLFolD X-IronPort-AV: E=Sophos;i="4.60,324,1291590000"; d="scan'208";a="86955600" Received: from mail-pz0-f54.google.com ([209.85.210.54]) by mail2-smtp-roc.national.inria.fr with ESMTP; 14 Jan 2011 22:59:31 +0100 Received: by pzk32 with SMTP id 32so495868pzk.27 for ; Fri, 14 Jan 2011 13:59:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=nAfqQrXw2udcfDPRtxJvPYgkOT1I14KwoFsqeWa/5To=; b=gF5T9a6QN6oWQntUnLbCc6FTAhHrtKaXUJzWD1FtVB8h58q38i5G03LVbj5ujjp6BY fDkF+hfqhCV5n1caVV8OrJ8j9/VV5Rw6H1DhR1CrHVDHETvNHGsBua3fzHCRspMHzk3W vG6pfsiOqZL7PDaWYMAnufmDjd/QNwpp7oA08= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=HnDCBp7qxtEuGBxqY8MHVeXdeT0lne+5uMUfNL8FgMeMYAIpKk+8IKROgO4waRXglx mDMtJ5oG9T6BOf0CNM5Nb3J2GLl9tELK2SpG7I//MGiPlDvb8b4fKNC/yaq8X4kGBj1s kL0O7RGXMK7Vao3MHbprUJEHEYWcTIXFVPaSE= MIME-Version: 1.0 Received: by 10.142.179.4 with SMTP id b4mr1192143wff.222.1295042370856; Fri, 14 Jan 2011 13:59:30 -0800 (PST) Sender: daniel.c.buenzli@gmail.com Received: by 10.142.73.8 with HTTP; Fri, 14 Jan 2011 13:59:30 -0800 (PST) In-Reply-To: References: Date: Fri, 14 Jan 2011 22:59:30 +0100 X-Google-Sender-Auth: HO2BbydOTnza4rBKl5pLT4zFmL8 Message-ID: From: =?UTF-8?Q?Daniel_B=C3=BCnzli?= To: Ashish Agarwal Cc: Caml List Content-Type: text/plain; charset=UTF-8 Subject: Re: [Caml-list] printing an exception changes printed backtrace > So it appears that printing an exception changes the backtrace. Is that > possible? I don't know about the details of backtrace recording but I suspect that the call to the printing function interferes with the previously recorded backtrace. What works for me is to immediately get the backtrace as a string [1] with Printexc.get_backtrace (), then print the exception and then print the string. Also bear in mind that sometimes native backtrace are not as precise as those in bytecode (tail calls and optimizations ?). Daniel [1] Btw. the api could really have given us a list of strings (or even of string * string * int * (int * int)). I already had to parse that string to properly format backtraces. 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 p0EM64u3021715 for ; Fri, 14 Jan 2011 23:06:07 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AiEBAB5XME3RVda2kGdsb2JhbACkUQgVAQECCQkMBxEEIKMYiXmCF4RKLoZSAQEDBYVKBIRrhis X-IronPort-AV: E=Sophos;i="4.60,324,1291590000"; d="scan'208";a="73102178" 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 23:06:06 +0100 Received: by iwn39 with SMTP id 39so3060273iwn.27 for ; Fri, 14 Jan 2011 14:06:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=OrhNETEoafUDh2zzF7h3Fh8JFpNOIKoMQSVhqCAIxqg=; b=seVPayaCOfumqJt6bKjfr8VwznCiJp5mj9FctxzHCzUlXtc9nzLVGZ8K4KGugo+NKm P3fE4qH5V7JxRR+sYiHTHexIt1RvvGcTd0Ya75t95B0aAA/yYbQKKMWJHXnbbn5vtM76 hxLFSP2T0nIOCoEkc+sLhzOxQ77RNhJLXw5y8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=DZtKKNrauj47mC2vKumL7busNxa7tEECfHZSNAnRyWtr3bEsrqZYGUx1h209cV4bdx bj0OulMmiDs4F8VrRu9rKhnqdAH2nzRx9BiC7nV9Cr7NClwV8U3iIWgNZlLcZ+xlqepl aUVcXMzPLGfQ3uov8MRcByk2/m9GdfbKobZz8= Received: by 10.231.36.69 with SMTP id s5mr1234116ibd.167.1295042765537; Fri, 14 Jan 2011 14:06:05 -0800 (PST) MIME-Version: 1.0 Received: by 10.231.14.10 with HTTP; Fri, 14 Jan 2011 14:05:44 -0800 (PST) In-Reply-To: References: From: Ashish Agarwal Date: Fri, 14 Jan 2011 17:05:44 -0500 Message-ID: To: =?ISO-8859-1?Q?Daniel_B=FCnzli?= Cc: Caml List Content-Type: multipart/alternative; boundary=0003255760020241830499d5a4ba Subject: Re: [Caml-list] printing an exception changes printed backtrace --0003255760020241830499d5a4ba Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Thanks for the workaround; that resolves the issue for me. But this seems very unstable. On Fri, Jan 14, 2011 at 4:59 PM, Daniel B=FCnzli wrote: > > So it appears that printing an exception changes the backtrace. Is that > > possible? > > I don't know about the details of backtrace recording but I suspect > that the call to the printing function interferes with the previously > recorded backtrace. > > What works for me is to immediately get the backtrace as a string [1] > with Printexc.get_backtrace (), then print the exception and then > print the string. > > Also bear in mind that sometimes native backtrace are not as precise > as those in bytecode (tail calls and optimizations ?). > > Daniel > > [1] > Btw. the api could really have given us a list of strings (or even of > string * string * int * (int * int)). I already had to parse that > string to properly format backtraces. > --0003255760020241830499d5a4ba Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Thanks for the workaround; that resolves the issue for me. But this seems v= ery unstable.


On Fri, Jan 14, 2011 a= t 4:59 PM, Daniel B=FCnzli <daniel.buenzli@erratique.ch> wrote:
> So it appears that p= rinting an exception changes the backtrace. Is that
> possible?

I don't know about the details of backtrace recording but I suspe= ct
that the call to the printing function interferes with the previously
recorded backtrace.

What works for me is to immediately get the backtrace as a string [1]
with Printexc.get_backtrace (), then print the exception and then
print the string.

Also bear in mind that sometimes native backtrace are not as precise
as those in bytecode (tail calls and optimizations ?).

Daniel

[1]
Btw. the api could really have given us a list of strings (or even of
string * string * int * (int * int)). I already had to parse that
string to properly format backtraces.

--0003255760020241830499d5a4ba-- From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p0HFbco4026552 for ; Mon, 17 Jan 2011 16:37:38 +0100 X-IronPort-AV: E=Sophos;i="4.60,333,1291590000"; d="scan'208";a="95636021" Received: from mp-57040.rocqadm.inria.fr ([128.93.57.40]) by mail1-relais-roc.national.inria.fr with ESMTP/TLS/AES128-SHA; 17 Jan 2011 16:37:33 +0100 Mime-Version: 1.0 (Apple Message framework v1082) Content-Type: text/plain; charset=windows-1252 From: xclerc In-Reply-To: Date: Mon, 17 Jan 2011 16:37:33 +0100 Cc: xclerc , Caml List Message-Id: <0AA39519-6C34-4620-9CFA-A99A3EC217CA@inria.fr> References: To: Ashish Agarwal X-Mailer: Apple Mail (2.1082) Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p0HFbco4026552 Subject: Re: [Caml-list] printing an exception changes printed backtrace Le 14 janv. 2011 à 22:15, Ashish Agarwal a écrit : > 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: It seems possible to reproduce the problem with the following source code: let custom_printer = true let () = if custom_printer then Printexc.register_printer (function | Not_found -> failwith "silently" | _ -> None) let rec f () = ignore (raise Not_found); f () let () = try f () with e -> Printf.eprintf "%s\n%!" (Printexc.to_string e); Printexc.print_backtrace stderr You will get different backtraces according to the value of "custom_printer". 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. In the code sample above, an exception is raised by the register custom printer. By design of "Printexc.to_string", such exceptions are silently ignored... but change the value of the last raised exception (and thus its associated backtrace). Your experience of the backtrace actually vanishing may be an instance of the same problem, where it just happens that the code for the custom printer has not been compiled with the "-g" option. Hope this helps, Xavier Clerc From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p0HGfdIF029763 for ; Mon, 17 Jan 2011 17:41:39 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgoBAOr/M03RVda2kGdsb2JhbACjdVYIFQEBAQEJCQwHEQQgqQOJeoIYhDouhnoBAQMFhUsEhHCGLw X-IronPort-AV: E=Sophos;i="4.60,333,1291590000"; d="scan'208";a="87137688" Received: from mail-iw0-f182.google.com ([209.85.214.182]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-MD5; 17 Jan 2011 17:41:33 +0100 Received: by mail-iw0-f182.google.com with SMTP id 39so5008538iwn.27 for ; Mon, 17 Jan 2011 08:41:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=w2oFS6VaU7+/ZSOWKe8mK9snrC/M+Qlfe+gvd3A1gm4=; b=OVipBMP3UBs5yyadCILnYptbblMB9noP2PQ5znvuxE9TIc+8pbxXvT5W4Ij219OQRb jW076mQikwJgUzswDkeOpSOy4DHldfT0jCkMfZC1Kz1du0Eh+sWVaxb03yOVK5Ik+Npp OBNWlgGQVbKPVO94erNC5v5z2REy8NgAcXiKA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=BFDeDiED87LSJX/23am6sVi2EX3+VDxjs9SRNABOb4fszmJ+GtxCf4j/mtBy3anAtb ylHzGAat3gCnMz09MPAGJoaOHFUExoXYR64J5AaKHt59DLa4D5WSpjdMK4Djmd8a4JGi BfrW2yWZarbK74H3Je9SDVqG0952Q5jAxZnnA= Received: by 10.231.39.67 with SMTP id f3mr4481639ibe.42.1295282493488; Mon, 17 Jan 2011 08:41:33 -0800 (PST) MIME-Version: 1.0 Received: by 10.231.14.10 with HTTP; Mon, 17 Jan 2011 08:41:13 -0800 (PST) In-Reply-To: <0AA39519-6C34-4620-9CFA-A99A3EC217CA@inria.fr> References: <0AA39519-6C34-4620-9CFA-A99A3EC217CA@inria.fr> From: Ashish Agarwal Date: Mon, 17 Jan 2011 11:41:13 -0500 Message-ID: To: xclerc Cc: Caml List Content-Type: multipart/alternative; boundary=00032557635ae8800c049a0d74a2 Subject: Re: [Caml-list] printing an exception changes printed backtrace --00032557635ae8800c049a0d74a2 Content-Type: text/plain; charset=ISO-8859-1 On Mon, Jan 17, 2011 at 10:37 AM, xclerc 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. let f () = try raise Not_found with Not_found -> () let g () = raise (Failure "") let () = try g() with e -> ( if true then f() else (); Printexc.print_backtrace stderr ) --00032557635ae8800c049a0d74a2 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On Mon, Jan 17, 2011 at 10:37 AM, xclerc <xavier.clerc@inria.= fr> wrote:
=A0
The underlying problem is that "Printexc.print_backtrace" prints = the backtrace
for the last exception raised... which can be one raised b= y "Printf.eprintf" or
"Printexc.to_string", but loca= lly caught and not exposed to the outside world.

Okay, that makes sense.=A0

<= /div>
=A0
You will get different b= acktraces 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 dif= ferent systems.

Based on your explanation, I was e= xpecting 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 unclea= r now as to what print_backtrace does.

let f () =3D
=A0=A0try raise Not_found
=A0=A0with Not_found -> ()

let g () = =3D raise (Failure "")

let () =3D
<= div>=A0=A0try g()
=A0=A0with e -> (
=A0=A0 =A0if true then f() else ();
=A0=A0 =A0Printexc.print_backtrace stderr
=A0=A0)


--00032557635ae8800c049a0d74a2-- From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p0HH2YEv031563 for ; Mon, 17 Jan 2011 18:02:34 +0100 X-IronPort-AV: E=Sophos;i="4.60,333,1291590000"; d="scan'208,217";a="87141352" Received: from zmbs4.inria.fr ([128.93.142.17]) by mail2-relais-roc.national.inria.fr with ESMTP; 17 Jan 2011 18:02:29 +0100 Date: Mon, 17 Jan 2011 18:02:29 +0100 (CET) From: Xavier Clerc To: Ashish Agarwal Cc: Caml List Message-ID: <560327307.145239.1295283749745.JavaMail.root@zmbs4.inria.fr> In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_145238_292378349.1295283749745" X-Originating-IP: [82.216.3.22] X-Mailer: Zimbra 6.0.10_GA_2692 (ZimbraWebClient - FF3.0 (Mac)/6.0.10_GA_2692) Subject: Re: [Caml-list] printing an exception changes printed backtrace ------=_Part_145238_292378349.1295283749745 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable ----- Mail original ----- De: "Ashish Agarwal" =20 =C0: "xclerc" =20 Cc: "Caml List" =20 Envoy=E9: Lundi 17 Janvier 2011 17:41:13=20 Objet: Re: [Caml-list] printing an exception changes printed backtrace=20 On Mon, Jan 17, 2011 at 10:37 AM, xclerc < xavier.clerc@inria.fr > wrote:= =20 The underlying problem is that "Printexc.print_backtrace" prints the backtr= ace=20 for the last exception raised... which can be one raised by "Printf.eprintf= " or=20 "Printexc.to_string", but locally caught and not exposed to the outside wor= ld.=20 Okay, that makes sense.=20 You will get different backtraces according to the value of "custom_printer= ".=20 I'm actually getting the same output (just "Not_found" printed). Tried nati= ve and byte code, on two different systems.=20 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 yo= u sure that you compiled the source with the "-g" option,=20 *and* set the OCAMLRUNPARAM environment variable to "b"?=20 Regards,=20 Xavier Clerc=20 ------=_Part_145238_292378349.1295283749745 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable <= div style=3D'font-family: Times New Roman; font-size: 12pt; color: #000000'= >


De: "Ashish Agarw= al" <agarwal1975@gmail.com>
=C0: "xclerc" <xavier.clerc@= inria.fr>
Cc: "Caml List" <caml-list@inria.fr>
Env= oy=E9: 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 backtr= ace
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 e= xpecting 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 no= w as to what print_backtrace does.
Are you sure tha= t you compiled the source with the "-g" option,
*and* set the OCAMLRUNPA= RAM environment variable to "b"?


Regards,

Xavier Clerc
= ------=_Part_145238_292378349.1295283749745-- From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p0HHD3lM032083 for ; Mon, 17 Jan 2011 18:13:03 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ag4BAP0GNE3RVda2kGdsb2JhbACCPaE4VggVAQEBAQkJDAcRBCCpCYl6ghiERC6GegEBAwWFSwSEcIYvhhw X-IronPort-AV: E=Sophos;i="4.60,333,1291590000"; d="scan'208";a="87143720" Received: from mail-iw0-f182.google.com ([209.85.214.182]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-MD5; 17 Jan 2011 18:12:57 +0100 Received: by iwn39 with SMTP id 39so5038257iwn.27 for ; Mon, 17 Jan 2011 09:12:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=5VADSbBRAakszXtOZ+b4tFbqfbmpsRSgbC6e6penOt0=; b=ov6TBGQrLxpOUgS+qmScoYdCWxUNRN0uPVtKpHK3cyiFr5TGr+zszyQooVcv1umpY3 1QkYBIZqvFv1xjEBNQWGD3KleqMmjoubB/OQ/+NRQp/9g+gGdevJ9M4d9wuJWOfY2BoM tfBu2MNOlwoXqBG6sN8fwi3qslrc+G2W2vUIU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=VfBSLfAAO5Vz+ChYTm0tDAMokitnGKYzn67CODXY0ZZ9MZ/Ck8dE8vGEEicx5caKjt zA+9+9cEtW4FkYny7p4gSg7g8tRYDNSFf073p6zRPJSQebGnjR+iaMoYCRtbWHAiEGXD RhPGtr44/MKqT4EFPJetMyX073pDyjl0s3I0U= Received: by 10.231.38.2 with SMTP id z2mr4469829ibd.142.1295284376625; Mon, 17 Jan 2011 09:12:56 -0800 (PST) MIME-Version: 1.0 Received: by 10.231.14.10 with HTTP; Mon, 17 Jan 2011 09:12:36 -0800 (PST) In-Reply-To: <560327307.145239.1295283749745.JavaMail.root@zmbs4.inria.fr> References: <560327307.145239.1295283749745.JavaMail.root@zmbs4.inria.fr> From: Ashish Agarwal Date: Mon, 17 Jan 2011 12:12:36 -0500 Message-ID: To: Xavier Clerc Cc: Caml List Content-Type: multipart/alternative; boundary=00221504879b26eab9049a0de519 Subject: Re: [Caml-list] printing an exception changes printed backtrace --00221504879b26eab9049a0de519 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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 wrote: > > > ------------------------------ > > *De: *"Ashish Agarwal" > *=C0: *"xclerc" > *Cc: *"Caml List" > *Envoy=E9: *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 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 > > --00221504879b26eab9049a0de519 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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 excepti= ons being raised that you don't see. Thanks for the explanations.


On Mon, Jan 17, 2011 at 12:02 PM, Xavier= Clerc <xavie= r.clerc@inria.fr> wrote:
De: "Ashish Agarwal" <= agarwal1975@gmai= l.com>
=C0: "xclerc" <xavier.clerc@inria.fr>
Cc: "Caml L= ist" <caml-= list@inria.fr>
Envoy=E9: 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:
=A0
The underlying problem is that "Printexc.print_backtrace" prints = the backtrace
for the last exception raised... which can be one raised b= y "Printf.eprintf" or
"Printexc.to_string", but loca= lly caught and not exposed to the outside world.

Okay, that makes sense.=A0

<= /div>
=A0
You = will get different backtraces according to the value of "custom_printe= r".

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

Based on your explanation, I was e= xpecting 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 unclea= r 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


--00221504879b26eab9049a0de519--