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 C19AC800FE for ; Tue, 21 Mar 2017 16:08:56 +0100 (CET) Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=romain.beauxis@gmail.com; spf=Pass smtp.mailfrom=romain.beauxis@gmail.com; spf=None smtp.helo=postmaster@mail-qt0-f181.google.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of romain.beauxis@gmail.com) identity=pra; client-ip=209.85.216.181; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="romain.beauxis@gmail.com"; x-sender="romain.beauxis@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of romain.beauxis@gmail.com designates 209.85.216.181 as permitted sender) identity=mailfrom; client-ip=209.85.216.181; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="romain.beauxis@gmail.com"; x-sender="romain.beauxis@gmail.com"; 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@mail-qt0-f181.google.com) identity=helo; client-ip=209.85.216.181; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="romain.beauxis@gmail.com"; x-sender="postmaster@mail-qt0-f181.google.com"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3AfVTprxfP4DK5QoyHzHPJM841lGMj4u6mDksu8pMi?= =?us-ascii?q?zoh2WeGdxc64ZR7h7PlgxGXEQZ/co6odzbGH7ua+CCdfud7B6ClEK8McEUddyI?= =?us-ascii?q?0/pE8JPo2sMQXDNvnkbig3ToxpdWRO2DWFC3VTA9v0fFbIo3e/vnY4ExT7Mhdp?= =?us-ascii?q?dKyuQtaBx+z+7e25+oXSbgNUn3L9JOoqdFTl5TnW4+wfkcNHLbsrwwfOvDMcfu?= =?us-ascii?q?1Gg2ZvOEiagxHizsCt4Jpk9CcWsPUkoZ1uS6L/Kp4/SLVZCnwMPmko9Mzw/U3Z?= =?us-ascii?q?Sg6G531aWGgfjwpJGCDK6Rj7WtH6tS6s5bk14zWTIcCjFeN8Yj+l9ao+DUaw0C?= =?us-ascii?q?o=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0BfBADuQNFYhrXYVdFeHAEBBAEBCgEBF?= =?us-ascii?q?gEBAQMBAQEJAQEBhDhZB4Nbm26JAIxEgg6GIgKDCwdBFgEBAQEBAQEBAQEBEgE?= =?us-ascii?q?BAQgLCwgoL4IzBAEdAQSCPAECAyMdARsdAQMMBgULDQICJgICIgERAQUBHAYTi?= =?us-ascii?q?WsBAxWeOT+MA4IEBQEcgwkFg2QKGScNVYIkAQEBAQEBBAEBAQEBGwIGEnmFQ4N?= =?us-ascii?q?mgQmHWoJfBY9cgQGFKYZKggWQQZEtkhcUH4EVJg41ciMWH1YXhDEggg0iNYdyg?= =?us-ascii?q?U8BAQE?= X-IPAS-Result: =?us-ascii?q?A0BfBADuQNFYhrXYVdFeHAEBBAEBCgEBFgEBAQMBAQEJAQE?= =?us-ascii?q?BhDhZB4Nbm26JAIxEgg6GIgKDCwdBFgEBAQEBAQEBAQEBEgEBAQgLCwgoL4IzB?= =?us-ascii?q?AEdAQSCPAECAyMdARsdAQMMBgULDQICJgICIgERAQUBHAYTiWsBAxWeOT+MA4I?= =?us-ascii?q?EBQEcgwkFg2QKGScNVYIkAQEBAQEBBAEBAQEBGwIGEnmFQ4NmgQmHWoJfBY9cg?= =?us-ascii?q?QGFKYZKggWQQZEtkhcUH4EVJg41ciMWH1YXhDEggg0iNYdygU8BAQE?= X-IronPort-AV: E=Sophos;i="5.36,198,1486422000"; d="scan'208";a="265528368" Received: from mail-qt0-f181.google.com ([209.85.216.181]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 21 Mar 2017 16:08:11 +0100 Received: by mail-qt0-f181.google.com with SMTP id x35so132868985qtc.2 for ; Tue, 21 Mar 2017 08:08:11 -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:to :cc; bh=PNLtA1tY+13PseeUxb8wiWvWjx8ps+s6c53+xmLbPUI=; b=JC+XtN+cYY15XBD90VijdPjDUCLBcrgGemxYB1kediHPtnhti1cRlEzI2GQMpdUpSe pyMA2Nipyd6ucYP07VLXc/LQPtdDkMtg5LuUJWsHnW14Odak0jvfJSECJ1KceV5e77wA 7NqqRPBZWcjtk2vnl0hhwzGBuNQjhV3eeQrO+I7kCYRhrxTy0dFfmQcQtJdQnCSdDzkR pAYwwLuEoxIsaFOT0woXTSxo64hOe11oZ/Xrld27RyA1MPvfkKSBObWcccKeG+r4pkVn S3hrpDItY1vxcMdgbJM2sBgOX2dwOEQFNBBp2gv1Xic76dVGqN2SzhRlJ3NUP9BZ0wB6 M6KA== 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:to:cc; bh=PNLtA1tY+13PseeUxb8wiWvWjx8ps+s6c53+xmLbPUI=; b=eDYJJSZIQNakXFOrzDujFNExntmhPAnbCHK61DqgKhO2WZdt/HRVE21Lkmp0qOkdHo PYKC4/p9a6P3EwGckju2ibdf1s9QFMu8vs9KYGoxLGYykJsR9GrdSQlXeXAi+Bh3miKk tIeh1ZY/36KPr5KtmTuL2HEckTnYGiz1f3kscgkc7JHs0rX/I++dcLVvKjPnqC3Ya5DL xUUhvAu4ljAuVJbLAillfhwK4+Fa9+mz0EyOTGmnDI7zNgoy3MSEm+IyBVd9tUTcggq4 7ETXVPCuzTl5L6OJsnNaY3DOYfKN40QUhQnhU/odjuV4t3CdufFX/Fa6lmskhI9pC/lh AtRw== X-Gm-Message-State: AFeK/H3s0sm628omsEdMT8dTeWQYJg3j9JeLkg8uAVMGo3plo7eo9d2+VKmz5SSNf23LSTe4kw+zyAJ3e1Eq6g== X-Received: by 10.237.59.150 with SMTP id r22mr31530447qte.100.1490108890393; Tue, 21 Mar 2017 08:08:10 -0700 (PDT) MIME-Version: 1.0 Received: by 10.200.1.6 with HTTP; Tue, 21 Mar 2017 08:07:50 -0700 (PDT) In-Reply-To: References: From: Romain Beauxis Date: Tue, 21 Mar 2017 10:07:50 -0500 Message-ID: To: Max Mouratov Cc: Dmitry Bely , "caml-list@inria.fr" Content-Type: text/plain; charset=UTF-8 Subject: Re: [Caml-list] Exceptions and Gc. 2017-03-21 6:58 GMT-05:00 Max Mouratov : > Tuesday, March 21, 2017, 12:22:54 AM, Romain wrote: >> 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.. > > Tuesday, March 21, 2017, 4:17:05 PM, Dmitry wrote: >> 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. > > It won't guarantee running all finalisers, as some of the objects may > still be reachable. As part of a yet unmerged patch [1] that will land > in 4.06, I have added an option that makes the runtime shut down > properly on process exit (by an implicit call to the new caml_shutdown > function), but unfortunately it doesn't handle Gc.finalise yet, as the > relevant logic is not so trivial (and is probably a subject for a > different PR). However, custom blocks [2] are guaranteed to be > finalised properly with caml_shutdown, so you might look into this. Thanks guys. That patch sounds great. I was just wondering since after all this time writing OCaml I never thought about it nor actually ready anything about this topic. Being able to clean everything up when the program exits seems like a reasonable feature. Romain