From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id yHbKFNtMYmMaAAEAbAwnHQ (envelope-from ) for ; Wed, 02 Nov 2022 11:56:27 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id EFnNFNtMYmPGZwAA9RJhRA (envelope-from ) for ; Wed, 02 Nov 2022 11:56:27 +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 F2DFD28AD9 for ; Wed, 2 Nov 2022 11:56:26 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oqBPh-0003ic-4m; Wed, 02 Nov 2022 06:56:05 -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 1oqBPe-0003fe-Rx for bug-guix@gnu.org; Wed, 02 Nov 2022 06:56:02 -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 1oqBPe-0007vR-Jg for bug-guix@gnu.org; Wed, 02 Nov 2022 06:56:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oqBPe-0006ZU-Aj for bug-guix@gnu.org; Wed, 02 Nov 2022 06:56:02 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#58732: installer: finalizers & device destroy segfault Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Wed, 02 Nov 2022 10:56:02 +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: Mathieu Othacehe Cc: 58732@debbugs.gnu.org Received: via spool by 58732-submit@debbugs.gnu.org id=B58732.166738655025237 (code B ref 58732); Wed, 02 Nov 2022 10:56:02 +0000 Received: (at 58732) by debbugs.gnu.org; 2 Nov 2022 10:55:50 +0000 Received: from localhost ([127.0.0.1]:45022 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oqBPR-0006Yz-LO for submit@debbugs.gnu.org; Wed, 02 Nov 2022 06:55:49 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39762) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oqBPP-0006Ym-3L for 58732@debbugs.gnu.org; Wed, 02 Nov 2022 06:55:48 -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 1oqBPI-0007ex-SS for 58732@debbugs.gnu.org; Wed, 02 Nov 2022 06:55:40 -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=419DFm+tOiFwtiMwlfo1GUu1yro6sxSSUaUg2SV0KcQ=; b=Qxs8xHAJffWGPlT9rkdA MlU6hxuO/ud7oytUxawaDgFy/OqEpqYr7MWPlvlFEoNpYn/cRR5K/9PWNDc/2qwuX1vUQWOBhbgt9 qEHGj4CwNswKc41bUbbmHEt/0j3vgdlSJ0rG/E8F+p6hq18Nd9yHXt9D/B7165QceTg4lyfb8d26m vCJeOUT0mmoVbADX2LwUj9gM3aTZRp+0i2LVrjVNTgjJqfvgt3KYjRsmp37SolVqfcv7d53RoXiUE MjOG7+gjlC7ZmBIF2y2Kxcwwf3jef4ed9AYZvAPpK7ZyDBOrzSpF0TCKVIntm1vOyFb3jpKzd1QtE mEL/mApXaLyrEQ==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oqBPI-00041S-FG; Wed, 02 Nov 2022 06:55:40 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <87v8oa29ik.fsf@gnu.org> Date: Wed, 02 Nov 2022 11:55:37 +0100 In-Reply-To: <87v8oa29ik.fsf@gnu.org> (Mathieu Othacehe's message of "Sun, 23 Oct 2022 11:07:31 +0200") Message-ID: <871qqlwrpy.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.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: , 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=1667386587; 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=419DFm+tOiFwtiMwlfo1GUu1yro6sxSSUaUg2SV0KcQ=; b=Avncllv8KzotpzIBf9rkVUaJj3FND7qXSpozoeTYPqr4Oa43N5wiHjOAA8h0xT30Vf4jtR 5MWQ7ohte8IU+uW8diCcU9wrCXhnhXPc9Hu7XcVK8f9ijIw05otgksQA6B/YKTZkqXDQ5v OjBiiwH2bm/xcq7ofUnoeVcAEBT9TTaIrqqXdhasjN014ZHy4xnTFExYr2H0Rj7SLj5vyL pCXqZCAgWeLgBOPE7HjmPXLKDGr9viFLYoXAK2eQ4gDQcnJBotUAkg9Jqp0piiUJXu5UH7 MUqqIyA7WJqtJJpDbR7LXHSDernvKztQGcphUl6Axv4g6z4Uhqd+7J4aRyFlSg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1667386587; a=rsa-sha256; cv=none; b=F6HdExDhpSGL47I8iEbTq9zahdstVeSQcdUwF3OSnZsG0SvErQNG3WOC8Xu5ggaE4LQmDx I6R10bN4HQFljwDygIoLEoSGBs9VMEgNWvwHZtUyKQG4H2pZADPe67VoOZ0dITrcPDF7Xh +kQEC0iUn/j0xISNCR44PKq0xbBLcwXOzTr0L1GHo9Dy28bGw4hoqf6qiodXPxWMipBO3n 74O2dTahFVFfVI2LTJ7kaYu93i9b2Ovpw/bHI8osz9NKinHVUXtRV6qmI7OXLIcQKLOnCK BBdiRaZ9CsxNwpA0F6gAAn+pGeNxAFGFNKQ8pOcgsNe/m9CUqQcDJJ1x9D/rbw== 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=Qxs8xHAJ; 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=Qxs8xHAJ; 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: F2DFD28AD9 X-Spam-Score: -3.89 X-Migadu-Scanner: scn1.migadu.com X-TUID: mJAmuBp5jK6A Hi, Mathieu Othacehe skribis: > null! I guess this has to deal with device pointer finalizers. I'm a bit > disappointed because I thought we had overcome those mistakes. There are several things we should audit in Guile-Parted regarding object lifecycles. Common issues when writing bindings that could cause problems like what you report: 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 po= inter P, you must make sure to return always the same wrapper and not create a new one. =E2=80=98pointer->device!=E2=80=99 attempts to do that but I think it= =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. =E2=80=98define-wrapped-pointer-type=E2=80=99 in Guile is meant to hel= p 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. 2. Scheme wrappers must mirror the aggregation relations of the C objects they wrap. For instance, let=E2=80=99s say a PedDisk aggregates PedPartition objects=E2=80=94i.e., that PedDisk =E2=80=9Cowns=E2=80=9D them and out= lives them. Then the Scheme wrappers must outlive the Scheme wrappers too, so that we don=E2=80=99t end up calling partition finalizers whil= e the disk that owns them is still alive. This is done using a weak-key hash table keyed by objects in this case and populated anytime a getter returns a . (See for example =E2=80=98%commit-owners=E2=80=99 in Guile-Git.) I think we should audit Guile-Parted with these issues in mind. WDYT? Ludo=E2=80=99.