From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id eO4DIuOhY2O7twAAbAwnHQ (envelope-from ) for ; Thu, 03 Nov 2022 12:11:31 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id 2HkFIeOhY2M6NQEAG6o9tA (envelope-from ) for ; Thu, 03 Nov 2022 12:11:31 +0100 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 24A3C2C830 for ; Thu, 3 Nov 2022 12:11:31 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oqY7m-00040B-5Q; Thu, 03 Nov 2022 07:11:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oqY6k-00038U-Dq for bug-guix@gnu.org; Thu, 03 Nov 2022 07:10:07 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oqY6k-0002LE-4q for bug-guix@gnu.org; Thu, 03 Nov 2022 07:10:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oqY6j-0006AX-VR for bug-guix@gnu.org; Thu, 03 Nov 2022 07:10:01 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#58732: installer: finalizers & device destroy segfault Resent-From: Mathieu Othacehe Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Thu, 03 Nov 2022 11:10:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58732 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 58732@debbugs.gnu.org Received: via spool by 58732-submit@debbugs.gnu.org id=B58732.166747377123632 (code B ref 58732); Thu, 03 Nov 2022 11:10:01 +0000 Received: (at 58732) by debbugs.gnu.org; 3 Nov 2022 11:09:31 +0000 Received: from localhost ([127.0.0.1]:48185 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oqY6F-000691-6W for submit@debbugs.gnu.org; Thu, 03 Nov 2022 07:09:31 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60174) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oqY6D-00068f-GB for 58732@debbugs.gnu.org; Thu, 03 Nov 2022 07:09:30 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oqY66-00025Q-AU; Thu, 03 Nov 2022 07:09:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=A+N3qOhoWsLfgLb5nHrslCHR6uzoANazMcdFgufdk6s=; b=iRqvZGsmtued/5n1MilZ 7cJSub64Zp65cWyhJWsGBttij0i9hCZ4XepqBr0jYU4vLUPMW+LXnLziS+BAGOk/vvorvPneOe0I5 Lx+EgsKsqE7oXEJlSdg4dqIaNdyNMRqzXgBC0fYPE+uIv6IhMW6legreYktjW3bR2eMRv12/RZkQc IwXeT+j5h5IibovGoztJMPzlL/dT6w+OrhVMHfFWMlkialHwtUKtBr3FUG3myte8EuOgYAf3O3Cmw zgnQvSksO/RgN+QHJ9sdLMjuqahYj3k7Gc3UaCZp4IdImBogQwTzLXzrqJjMH6AoyT5UgCDYY5EOH ms+vBw48C5r+OQ==; Received: from 2a02-8429-81d2-3d01-94c9-8097-ea5c-2775.rev.sfr.net ([2a02:8429:81d2:3d01:94c9:8097:ea5c:2775] helo=meije) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oqY64-00036K-FA; Thu, 03 Nov 2022 07:09:21 -0400 From: Mathieu Othacehe References: <87v8oa29ik.fsf@gnu.org> <871qqlwrpy.fsf@gnu.org> Date: Thu, 03 Nov 2022 12:09:16 +0100 In-Reply-To: <871qqlwrpy.fsf@gnu.org> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Wed, 02 Nov 2022 11:55:37 +0100") Message-ID: <87iljwuwf7.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (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: , Sender: "bug-Guix" Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1667473891; 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:dkim-signature; bh=A+N3qOhoWsLfgLb5nHrslCHR6uzoANazMcdFgufdk6s=; b=JwanfYjsri5XRQDmwK/oS7kX71Xr7dDftGWy434Tx+khE1hWAnIDdybWe+h4usCnC/Dk/v xS55t3SJD8r/Jj96hdH8XC/tC8b1y2pV59lyajItr2sD4PQs0GWANi8R/GF+3icfx49Kcj sDI0JSsHwYW2XK8JUygM1mIamFmlb2jTrfgYo6HiwDV5abXVD9P1+PWQeWMSk9IKhE8JjA JGJc9wCHTIgY6CLqOfvMYgqwAgrwEiZSNGC39xt45YoirqCF6l9Dj1fwFr6kj8qfQYLN13 QnvZcN56cXDHNGDANR5/D0BJVufPLS9J43nR3aidJdC6Ra3TK/nUz6AC3g3PrQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1667473891; a=rsa-sha256; cv=none; b=CSzefFNL1t0vHWBcBIqwyyW3FaPHE5NtlVLv3aTjAg7j8wQiLJ1EvJG5caIpE0fJAWbF8/ pMxtjYlQI9gBTCwyliJRzm2pL3SGl6IbbN3XyJ3Qua87FpRlTYEV96WvbtAKLZekfYTcUk JZtu+c2vvH9E0Dd4EX0b8z4BQLu3sPFW+Z9qAN4VpVChL3v7Nx9C2VfEHfzJ08TjDjigfk qbEVvDF7MD/JZ+69kb+p90FO6f+349ylXxYlPRb3EdZa2BQZnZP9RKOCI40MDX3ekboBcD Vf5PaACw/8hJ9DmZupD2TiE1iBB8F2sSOqfZUaF746ejaD21MhzajpBJeMtbpA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=iRqvZGsm; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.89 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=iRqvZGsm; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 24A3C2C830 X-Spam-Score: -3.89 X-Migadu-Scanner: scn1.migadu.com X-TUID: aBSNYs9tLvYy Hey, Thanks for your help :) > 1. Bindings create wrappers for C pointers=E2=80=94e.g., with > =E2=80=98pointer->device=E2=80=99. If several C functions return a = pointer P, you > must make sure to return always the same wrapper and not create a > new one. Agreed. > > =E2=80=98pointer->device!=E2=80=99 attempts to do that but I think i= t=E2=80=99s bogus: it > uses a weak-value hash table, where the value is the wrapper. So > if the wrapper disappears before the underlying C object, then the > pointer is called and bad things ensue. I'm not sure to understand how could the wrapper disappear before the underlying C object? We are only exposing records to the Guile-Parted users so my assumption is that when goes out of scope, the pointer it wraps can be freed, but I'm maybe missing something? > =E2=80=98define-wrapped-pointer-type=E2=80=99 in Guile is meant to h= elp with these > things (info "(guile) Void Pointers and Byte Access"). We can=E2=80= =99t > use it directly here because we=E2=80=99re using bytestructures and = all > that. Turns out, the "wrap" procedure defined in define-wrapped-pointer-type is a clone of pointer->device! except that it doesn't set a finalizer. Regarding object lifetime, I wrote a small memo in 2019 here: https://issues.guix.gnu.org/36402#11. We have three weak hash tables in Guile-Parted: %devices: To make sure that we do not set multiple finalizers on the same pointers. %disk-devices: So that a device always outlives its disks. %partition-disks: So that a disk always outlives its partitions. This means that as far as I can tell we are OK regarding your second point about "aggregation relations". Mathieu