From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id mG3sNdtCPmDDEQAA0tVLHw (envelope-from ) for ; Tue, 02 Mar 2021 13:51:23 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id QFvEMdtCPmDIdQAA1q6Kng (envelope-from ) for ; Tue, 02 Mar 2021 13:51:23 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id E937119146 for ; Tue, 2 Mar 2021 14:51:22 +0100 (CET) Received: from localhost ([::1]:41070 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lH5Qn-0002f0-QA for larch@yhetil.org; Tue, 02 Mar 2021 08:51:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53910) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lH5QU-0002OQ-I4 for bug-guix@gnu.org; Tue, 02 Mar 2021 08:51:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:40563) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lH5QU-0004pE-Ai for bug-guix@gnu.org; Tue, 02 Mar 2021 08:51:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lH5QU-0000qe-9V for bug-guix@gnu.org; Tue, 02 Mar 2021 08:51:02 -0500 X-Loop: help-debbugs@gnu.org Subject: bug#46796: Cuirass & pointer finalization. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Tue, 02 Mar 2021 13:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46796 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Mathieu Othacehe Received: via spool by 46796-submit@debbugs.gnu.org id=B46796.16146930123202 (code B ref 46796); Tue, 02 Mar 2021 13:51:02 +0000 Received: (at 46796) by debbugs.gnu.org; 2 Mar 2021 13:50:12 +0000 Received: from localhost ([127.0.0.1]:52107 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lH5Pg-0000pa-Fn for submit@debbugs.gnu.org; Tue, 02 Mar 2021 08:50:12 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35834) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lH5Pe-0000pJ-MA for 46796@debbugs.gnu.org; Tue, 02 Mar 2021 08:50:11 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:40426) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lH5PZ-0004dZ-FD for 46796@debbugs.gnu.org; Tue, 02 Mar 2021 08:50:05 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=38900 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1lH5PX-0006Iz-9e; Tue, 02 Mar 2021 08:50:03 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <8735xihq60.fsf@gnu.org> <87ft1hvfm4.fsf@gnu.org> <87k0qrusde.fsf@gnu.org> <87mtvmnfjb.fsf@gnu.org> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 12 =?UTF-8?Q?Vent=C3=B4se?= an 229 de la =?UTF-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Tue, 02 Mar 2021 14:50:01 +0100 In-Reply-To: <87mtvmnfjb.fsf@gnu.org> (Mathieu Othacehe's message of "Tue, 02 Mar 2021 09:08:56 +0100") Message-ID: <87blc1oeba.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 46796@debbugs.gnu.org Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1614693083; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=WGJQ6jPRnqFXvcaWgwWH3QJPoTc0wsvCJ7v1UWIo/D8=; b=BT4x0SgOiI+pJBW/89skSTnxbWbXd0Q1LI8TLglYH2GbWV2p1fz5r8A+zhVUYmTXln/gfz 3cnln/nwkyM87cnFBesvpIzIblTWmoN5EAgtQ8n5qXH07Ys9v3OSol9qsQKBHBa8QSjL1a 9XeHzw8fsqRFS1PDLSGLttZe+szZhgbsNtwuoJGvjK47LqTeS1lJQRn8hkjqxRPF1gPfLg cEJmtMBXtg10nH3Je2yy9uBzWwNVB72dG82V99nqMqvuIpbtC9O0EPZDcAze9DvSAoI9oF LSuRYjK5qB4i9fq7qt2U/nNkQHOITXZFobvwHMtcUed04ZUUT1ywuxaT4I3Vqw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1614693083; a=rsa-sha256; cv=none; b=sTsszy917ftN4sSTiRELZcxedTVhsXe44SM/dXzZNV+d/rARtSSrBP9dMWpNvp1cdMb2s4 En9KiDzOKHJso3Tay45YwB7YzsOhqzW0YW2DTR2CEuHkNXnJaT3shsIw/jXi/0sURP8zGo na6OAbsWKodVlnHqZc+6hQYfvO0krR/PrFgmVIpAC8o4fOZ8NqMWsdlOb1I5JBSh1p7odO aiM45BtTZSW5am8C6F6f6lM7OiTX86g/eRsnU1OXQGZ1P7o47ed5BfXajkajHT8x1aHpnT tFJZEs9q+J3aUQTzMkkmI0Gy+fSjJFHCR3L+eaAmA6nnv10LFBvCRkTsdTXVcg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of bug-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=bug-guix-bounces@gnu.org X-Migadu-Spam-Score: -2.86 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of bug-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=bug-guix-bounces@gnu.org X-Migadu-Queue-Id: E937119146 X-Spam-Score: -2.86 X-Migadu-Scanner: scn1.migadu.com X-TUID: rXTwgoYMBny6 Hi! Mathieu Othacehe skribis: > I have written a small reproducer of the situation: > > (use-modules (system foreign) > (rnrs bytevectors)) > > (define close > (dynamic-func "test_close" (dynamic-link "/home/mathieu/tmp/libtest"))) > > (let loop () > (let* ((bv (make-bytevector 64)) > (ptr (bytevector->pointer bv))) > (set-pointer-finalizer! ptr close) > (loop))) > > > this program creates a bytevector of 64 bytes and attaches the C > function "test_close" as a pointer finalizer to the bytevector pointer. > > This function looks like: > > int > test_close (void *x) > { > int i; > char *v =3D x; > > for (i =3D 0; i < 64; i++) { > v[i] =3D '1'; > } > > return 0; > } > > It overrides the bytevector content, that should cause a segmentation > error if the bytevector is already freed. > > And it does indeed, which makes me think that despite the weak reference > between the pointer object and the bytevector, the bytevector is already > GC'd when the finalizer is called. Hmm I think the bytevector and the pointer object can be finalized in the same GC cycle; when that happens, you have no guarantee as to the order in which they are finalized. IOW, I think you cannot assume, from the pointer finalizer, that the bytevector is still reachable. But=E2=80=A6 is it really similar to your ZMQ issue? There you had message object wrappers (as per =E2=80=98define-wrapped-pointer-type=E2=80=99) and = a pointer object to the underlying C object, right? > I'm now using guardians in Guile-Simple-ZMQ instead of pointer > finalizers, and do not experience crashes anymore, but I would really > like to understand what's happening here. Guardians are finalizers; it=E2=80=99s just a different interface. Ludo=E2=80=99.