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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id CC45D800FE for ; Tue, 21 Mar 2017 12:17:07 +0100 (CET) Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=dmitry.bely@gmail.com; spf=Pass smtp.mailfrom=dmitry.bely@gmail.com; spf=None smtp.helo=postmaster@mail-qk0-f170.google.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of dmitry.bely@gmail.com) identity=pra; client-ip=209.85.220.170; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="dmitry.bely@gmail.com"; x-sender="dmitry.bely@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of dmitry.bely@gmail.com designates 209.85.220.170 as permitted sender) identity=mailfrom; client-ip=209.85.220.170; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="dmitry.bely@gmail.com"; x-sender="dmitry.bely@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-qk0-f170.google.com) identity=helo; client-ip=209.85.220.170; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="dmitry.bely@gmail.com"; x-sender="postmaster@mail-qk0-f170.google.com"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3AMykW9BCSZenFReF4+DYbUyQJP3N1i/DPJgcQr6Af?= =?us-ascii?q?oPdwSPv8psbcNUDSrc9gkEXOFd2CrakV1qyI4uu6BSQp2tWoiDg6aptCVhsI24?= =?us-ascii?q?09vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6nK94iQPFRrhKAF7?= =?us-ascii?q?Ovr6GpLIj8Swyuu+54Dfb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-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0DaAwBXCtFYhqrcVdFeHAEBBAEBCgEBG?= =?us-ascii?q?AEFAQsBhDhLDgeDW5tALZdShiICJoJiB0MUAQEBAQEBAQEBAQESAQEBCAsLCCg?= =?us-ascii?q?vgjMigjgJAQIDIx0BGx0BAwwGBQsNAgImAgIhAQERAQUBHBmFcoN5AQMVnXc/j?= =?us-ascii?q?AOCBAUBHIMJBYNqChknDVWCLwEBCAEBAQEcAgYSeYVDhG+CUYUJEoJNBZBZhSy?= =?us-ascii?q?GDzqCBYwPhDKRLYpqhywUH4EVNoElIxYfVhdPDINWDBQMgWY9NYlBAQEF?= X-IPAS-Result: =?us-ascii?q?A0DaAwBXCtFYhqrcVdFeHAEBBAEBCgEBGAEFAQsBhDhLDge?= =?us-ascii?q?DW5tALZdShiICJoJiB0MUAQEBAQEBAQEBAQESAQEBCAsLCCgvgjMigjgJAQIDI?= =?us-ascii?q?x0BGx0BAwwGBQsNAgImAgIhAQERAQUBHBmFcoN5AQMVnXc/jAOCBAUBHIMJBYN?= =?us-ascii?q?qChknDVWCLwEBCAEBAQEcAgYSeYVDhG+CUYUJEoJNBZBZhSyGDzqCBYwPhDKRL?= =?us-ascii?q?YpqhywUH4EVNoElIxYfVhdPDINWDBQMgWY9NYlBAQEF?= X-IronPort-AV: E=Sophos;i="5.36,198,1486422000"; d="scan'208";a="217499573" Received: from mail-qk0-f170.google.com ([209.85.220.170]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 21 Mar 2017 12:17:06 +0100 Received: by mail-qk0-f170.google.com with SMTP id p64so131965804qke.1 for ; Tue, 21 Mar 2017 04:17:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:cc; bh=26ABgP9EOXkQ3mnmmDBX1t9IFTRJy0AfxdTtpOMAnsU=; b=FO8jJOLVzWHHyrRfWk4KArBNooNTfeqdCotQ17XrfG56Uhy+m6s01L4OapLajm+/9o 2XbrRPJzc3wrFbgg0UVEE0zRSC3XDGXtuGqcTeclDTWL67zBscTiNyyHxhV6aHra0nTF hm8UXL2HX9khn2R2qWAWS8EwGm8FLlkDq2fUiXfqPhLUacp7ubjE+6ehOMXUXVVCc/QJ YFEkTwdxmoRD0uN3II7MaFnUtpgY/wcnJE6yP9BPF3aBIrmMhHHRfp0OjPoHf+j2YCWI IOOhqO6QM27OibH2BD9TrY67HewxWeR1ukOzhSPI0DrqoX5oq7N7ohYjm5ednNIpfOYv AtYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:cc; bh=26ABgP9EOXkQ3mnmmDBX1t9IFTRJy0AfxdTtpOMAnsU=; b=oJknsyd3v5dsYfngs3YL+oTiw9W08FWkka2Rx1tChsOEKjmCt3N8eVwTyXi0yhokn+ 578VxEwMl8rO1+du26pjZVSQIGpOL4qCpCKW8VbT3Bk5wq7vZ7Xv5O3faatmGopDzCWQ 8NUMUIUCigoMVUfL4qK1vicT4ujxItA1YIJRpIhAWydWJU6EDVDLNF1Kwuy3fad6yU4c qDCgAzUpOUK3AMbYUeBL1bw9bmgJbOqGeYaGvA4LbeEVyE1cMMIF62jOR9DZwFo4D4bj 99yhEGpF8QBoRWmdvUvIXeAVpc8uKNadzOZezfr4MLAcLMBa7lkcn5CiV9k6qqXUMUL4 9FyA== X-Gm-Message-State: AFeK/H22juqCHuz9lSXJ4+df3k4bqsqw5euqEn3SIoaqcqVgHmFcFQzRXuK8NH9g1XsUTu8hmkbwJJqFHflqpA== X-Received: by 10.55.125.68 with SMTP id y65mr7084250qkc.83.1490095025571; Tue, 21 Mar 2017 04:17:05 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.154.222 with HTTP; Tue, 21 Mar 2017 04:17:05 -0700 (PDT) In-Reply-To: References: From: Dmitry Bely Date: Tue, 21 Mar 2017 14:17:05 +0300 Message-ID: Cc: OCaml List Content-Type: text/plain; charset=UTF-8 Subject: Re: [Caml-list] Exceptions and Gc. It has nothing to do with exceptions. The problem is that OCaml runtime does not execute the garbage collector on program exit. But you can write let _ = at_exit Gc.full_major if you need to force GC. On Mon, Mar 20, 2017 at 10:22 PM, Romain Beauxis wrote: > Hi guys, > > Apologies if I'm beating a dead horse but I think I've never wondered about > this: What are the assumptions related to the garbage collector when an > exception is raised? > > I sort-of always assumed it would be run but it doesn't seem that this is > the case. This code: > let () = > let g () = > let f _ = > Printf.printf "Collecting x\n%!" > in > let x = Bytes.create 1024 in > Gc.finalise f x; > () > in > g (); > Gc.full_major(); > raise Not_found > > Shows that the finalization function is never call if I remove the call to > full_major. Any reason for that? > > The reason I'm asking if that I know I've been writing C bindings where some > cleanup operations are wrapped up in the finalization code with the > expectation that, except for a hard crash, it would always be executed at > some point in the future.. > > Thanks for y'all comments! > Romain - Dmitry Bely