From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 0FA1DBBAF for ; Fri, 12 Mar 2010 16:00:53 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkMBAEblmUtQW+UMmWdsb2JhbACDDJdfFQEBAQEBCAsKBxMiqnSQJoEygl9qBIMX X-IronPort-AV: E=Sophos;i="4.49,626,1262559600"; d="scan'208";a="54498738" Received: from lo.gmane.org ([80.91.229.12]) by mail1-smtp-roc.national.inria.fr with ESMTP; 12 Mar 2010 16:00:52 +0100 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1Nq6M7-0007BF-RT for caml-list@inria.fr; Fri, 12 Mar 2010 16:00:51 +0100 Received: from elehack.net ([216.243.177.100]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 12 Mar 2010 16:00:51 +0100 Received: from michael by elehack.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 12 Mar 2010 16:00:51 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: caml-list@inria.fr From: Michael Ekstrand Subject: Strangeness with atexit and exception backtraces Date: Fri, 12 Mar 2010 09:00:31 -0600 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: elehack.net User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Lightning/1.0b1 Thunderbird/3.0.3 X-Enigmail-Version: 1.0.1 X-Spam: no; 0.00; atexit:01 atexit:01 backtrace:01 ocaml:01 bug:01 ocaml:01 terminates:01 stack:01 exception:01 exception:01 modifying:02 workaround:03 handler:03 handler:03 debugging:03 I have been using the Bolt logging library[1] lately in my code, but have encountered a difficulty with debugging programs. Bolt uses an atexit handler to close all open log files when the program shuts down. However, if an uncought exception is encountered with this atexit handler in place, the program terminates with status 2 but neither the exception value nor its backtrace (with OCAMLRUNPARAM=b) are printed. If I disable the atexit handler, the error information is printed as I expect. I am currently working around this by modifying Bolt so that the atexit handler is disabled if OCaml starts up with stack traces enabled. I am wondering, though, if this is a known bug (or limitation)? Is there another workaround, or a fix on the horizon? Or should I go file the appropriate report in the OCaml bugtracker? Thanks, - Michael