From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 1324F7F1AA for ; Wed, 9 Sep 2015 21:18:26 +0200 (CEST) IronPort-PHdr: 9a23:vIwxLxXH6usEqzLyWK/Fo231x7jV8LGtZVwlr6E/grcLSJyIuqrYZhGOt8tkgFKBZ4jH8fUM07OQ6PC8HzVcqs/a6DgrS99laVwssY0uhQsuAcqIWwXQDcXBSGgEJvlET0Jv5HqhMEJYS47UblzWpWCuv3ZJQk2sfTR8Kum9IIPOlcP/j7n0oM2PJVwUz2PmOftbF1afk0b4joEum4xsK6I8mFPig0BjXKBo/15uPk+ZhB3m5829r9ZJ+iVUvO89pYYbCf2pN5IRFuMDSWx6eyBovIy4/SXEGACG439ZVmQNjjJJBRLE5Vf0RMTfqCz/48N71CSAJoXOQKw5Q3yM8qhuQRnuwHMOMTI06nr/hNF/iatdplSnqgApkN2cW52cKPcrJvCVRtgdX2cUA55c Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=anders@fugmann.net; spf=Pass smtp.mailfrom=anders@fugmann.net; spf=None smtp.helo=postmaster@gw.fugmann.net Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of anders@fugmann.net) identity=pra; client-ip=90.184.182.235; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="anders@fugmann.net"; x-sender="anders@fugmann.net"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of anders@fugmann.net designates 90.184.182.235 as permitted sender) identity=mailfrom; client-ip=90.184.182.235; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="anders@fugmann.net"; x-sender="anders@fugmann.net"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@gw.fugmann.net) identity=helo; client-ip=90.184.182.235; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="anders@fugmann.net"; x-sender="postmaster@gw.fugmann.net"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0D5BAAFhfBV/+u2uFpRDIJ2LFRpgySweYsHh0Q8EAEBAQEBAQEBgQmCHYIqBgQRCAEBNgI0AgUWCwILAwIBAgFYCAKIKwO1LXGEZQEFj1gGgSKOcAGBBYJSgUOHNo4lcYQZigKYZiaBSgEKAQEBgipviEkBAQE X-IPAS-Result: A0D5BAAFhfBV/+u2uFpRDIJ2LFRpgySweYsHh0Q8EAEBAQEBAQEBgQmCHYIqBgQRCAEBNgI0AgUWCwILAwIBAgFYCAKIKwO1LXGEZQEFj1gGgSKOcAGBBYJSgUOHNo4lcYQZigKYZiaBSgEKAQEBgipviEkBAQE X-IronPort-AV: E=Sophos;i="5.17,498,1437429600"; d="scan'208";a="176742877" Received: from gw.fugmann.net ([90.184.182.235]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/ADH-AES256-GCM-SHA384; 09 Sep 2015 21:18:25 +0200 Received: from [IPv6:2001:470:dc46:1:daa2:5eff:fe95:453e] (zaphod.fugmann.net [IPv6:2001:470:dc46:1:daa2:5eff:fe95:453e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by gw.fugmann.net (Postfix) with ESMTPSA id B8DDB2922F8A for ; Wed, 9 Sep 2015 21:18:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fugmann.net; s=mail; t=1441826302; bh=DefzxyV2PY/VKyrtsus1l5AIr2ugS34eL9RdijUL7E0=; h=To:From:Subject:Date:From; b=GIbXREUwt8zmqT7bZDSzSDFoDkWECPnkXM81WZAEVMqAZyApEZtNvwVx0rmR5ByZo SOHuUqpZZ2lfPMhDDP1kbwMc2RQex4zx7lPKgUpa9WTy2cNlzKfAuus1XFYzMd5WC/ Crv1jsZk98s8ERlb+DLqD5iUN7WAR8besidSfm7s= To: caml-list@inria.fr From: Anders Peter Fugmann Message-ID: <55F085FE.7010809@fugmann.net> Date: Wed, 9 Sep 2015 21:18:22 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.1.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: [Caml-list] Exceptions and backtraces Hi, I'm trying to understand what to expect from backtraces when an exception is raised. The library reference says: --------------- val print_backtrace : out_channel -> unit Printexc.print_backtrace oc prints an exception backtrace on the output channel oc. The backtrace lists the program locations where the most-recently raised exception was raised and where it was propagated through function calls. --------------- The documentation seems to suggest that every function call site leading up to the exception would be part of the backtrace. However, when I execute the following program: --------------- let trace () = let open Printexc in get_callstack 2 |> backtrace_slots |> (function Some [| _;s |] -> s) |> Slot.location |> (function Some l -> l.line_number) |> Printf.printf "At Line: %d\n" exception Stop let a () = trace (); raise Stop let b () = trace (); a () let () = trace (); b () -------------- The code produces (both byte and native compilation): (ocaml 4.02.3 and 4.03-trunk) At Line: 13 At Line: 12 At Line: 11 Fatal error: exception Exception.Stop Raised at file "exception.ml", line 11, characters 27-31 Called from file "exception.ml", line 13, characters 21-25 The backtrace does not record the function call at line 12, even though the information is there (accessible though 'get_callstack'), so I assume that inlining is not causing the behaviour. Is it expected that the backtrace does not contain a reference for line 12, or is there some exception handling optimization I should be aware of? /Anders