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 CC20E7F750 for ; Mon, 20 Mar 2017 20:23:16 +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=3A4/Zajh2GnBSTW67CsmDT+DRfVm0co7zxezQtwd8Z?= =?us-ascii?q?segXLvad9pjvdHbS+e9qxAeQG96KtrQa1KGP6fmoGTRZp83e4DZaKN0EfiRGoP?= =?us-ascii?q?tVtjRoONSCB0z/IayiRA0BN+MGamVY+WqmO1NeAsf0ag6aiHSz6TkPBke3blIt?= =?us-ascii?q?dazdU7TfhMWv1u2054abI0AR3GL8MvtOK0CRhgzUsoEygJB+YvI6wx7N539JYP?= =?us-ascii?q?h+xGVyJFvVkQyqtemq+5s2ySNVsvMnv+RNWLjqfr9wGaZfCT0nNSY/6cT2pRjY?= =?us-ascii?q?ZQSK73oYFG4Rl0wbUED+8BjmU8Kp4WPBve1n1XzfZJWuQA=3D=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0A+AgBzK9BYf7XYVdFeHhgHCwEFAQsBh?= =?us-ascii?q?REHg1ukbYxDgg4MiSAHQRYBAQEBAQEBAQEBARIBAQkLCwgmMYIzBAEdAQSCZR0?= =?us-ascii?q?BGx4DEgkBBjcCJAERAQUBIol6AQMVmSGDRD+MA4IEBQEcgwkFg2MKGScNVYJZA?= =?us-ascii?q?gYShjyMDwwugl8FkF2FJ4ZJgVMxkD+RK5IQFB+BFSYDgTIjFh9thD0gggEiNYg?= =?us-ascii?q?cgU8BAQE?= X-IPAS-Result: =?us-ascii?q?A0A+AgBzK9BYf7XYVdFeHhgHCwEFAQsBhREHg1ukbYxDgg4?= =?us-ascii?q?MiSAHQRYBAQEBAQEBAQEBARIBAQkLCwgmMYIzBAEdAQSCZR0BGx4DEgkBBjcCJ?= =?us-ascii?q?AERAQUBIol6AQMVmSGDRD+MA4IEBQEcgwkFg2MKGScNVYJZAgYShjyMDwwugl8?= =?us-ascii?q?FkF2FJ4ZJgVMxkD+RK5IQFB+BFSYDgTIjFh9thD0gggEiNYgcgU8BAQE?= X-IronPort-AV: E=Sophos;i="5.36,195,1486422000"; d="scan'208,217";a="265385679" Received: from mail-qt0-f181.google.com ([209.85.216.181]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 20 Mar 2017 20:23:16 +0100 Received: by mail-qt0-f181.google.com with SMTP id n21so115389388qta.1 for ; Mon, 20 Mar 2017 12:23:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=NX5NLthmNta4JADx1gBqsgtsziQoJ8942rwxKVXkdvY=; b=vdH3kmGMWArASOIQyiQ7s1YPSBhia+T5K5yFToopE7zakWovTqDvSXHTHSiCh3kU38 J2WKezJRVICOIFGWMDYZM9qrO3a6vXxttjlXzWdPycN6lTv+I+RImHWthmc9O3LT5IN1 aVn+lSgYMdY5rtzYmrIXCQ/R/DPhaqsBAvDtwkWUHzz4VvT06sAh3YFFbaKrYk1Vo73K jbz+AQi/dDROB2tdeX32yhDbjqUqE7ctFydQ9tZe5VFiyXb/IznVt/zwQc/sLKGYyBbq uqfm7xEIMHjXWBDT8lpiniJT17gpP2WpspMyAvMeRyinZ1LnbmbkTyXI6zxx91vCxebI xWfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=NX5NLthmNta4JADx1gBqsgtsziQoJ8942rwxKVXkdvY=; b=tllmKDIsah221ZBbtx7vsavTz5B4s5CFrXSFFd2rB3EnGl7EdkiBzDjccLp0KNO9U3 ovqQsxT1DKk3WbwuITJ9+sjf0WXeWr/7NUFhOOOTbmg8uLopqUNxv3YAnBa6E0NrU0Tm Gb2EE8+8/gfm/XG/IwUGDfKrVW4tDnSCa8mG4tksWqStvaNlMZsfn5/wbPUw1h6ShQ0h 0ayezY4FHDPj5P7zAENUZVGesf3g1UMjImaehWfXe//ha0tcpHBGGX9wjJv5cbRQy7oc omxaZ05Ip2Pj9jHc9fm1e+4JpnFXHmmHzwZVnwJHEspvsHT8BfQhmt2EKDNb67pnyFmO HPmg== X-Gm-Message-State: AFeK/H29o0ay+o8xoA6tuHaJ4Y9F/TFdQ2i8lgPKCqeNa43T98AGg50cu0cFkROkfIVGCavv7bCxGqnQoJL8/A== X-Received: by 10.200.45.194 with SMTP id q2mr29438925qta.130.1490037794503; Mon, 20 Mar 2017 12:23:14 -0700 (PDT) MIME-Version: 1.0 Received: by 10.200.1.6 with HTTP; Mon, 20 Mar 2017 12:22:54 -0700 (PDT) From: Romain Beauxis Date: Mon, 20 Mar 2017 14:22:54 -0500 Message-ID: To: OCaml List Content-Type: multipart/alternative; boundary=001a1143c0a0718555054b2e755a Subject: [Caml-list] Exceptions and Gc. --001a1143c0a0718555054b2e755a Content-Type: text/plain; charset=UTF-8 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 --001a1143c0a0718555054b2e755a Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi guys,

Apologies if I'm beating a= dead horse but I think I've never wondered about this: What are the as= sumptions 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 () =3D
=C2=A0 let g () =3D
=C2=A0 =C2=A0 let f _ =3D
= =C2=A0 =C2=A0 =C2=A0 Printf.printf "Collecting x\n%!"
= =C2=A0 =C2=A0 in
=C2=A0 =C2=A0 let x =3D Bytes.create 1024 in
=C2=A0 =C2=A0 Gc.finalise f x;
=C2=A0 =C2=A0 ()
= =C2=A0 in
=C2=A0 g ();
=C2=A0 Gc.full_major();
=C2=A0 raise Not_found

Shows that the fina= lization function is never call if I remove the call to full_major. Any rea= son for that?

The reason I'm asking if that I = know I've been writing C bindings where some cleanup operations are wra= pped up in the finalization code with the expectation that, except for a ha= rd crash, it would always be executed at some point in the future..

Thanks for y'all comments!
Romain
--001a1143c0a0718555054b2e755a--