From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.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 EAmHFJQ0aWMxRAEAbAwnHQ (envelope-from ) for ; Mon, 07 Nov 2022 17:38:44 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id uF2eFJQ0aWPUZQEA9RJhRA (envelope-from ) for ; Mon, 07 Nov 2022 17:38:44 +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 EA49217498 for ; Mon, 7 Nov 2022 17:38:43 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1os58O-0006mA-Pm; Mon, 07 Nov 2022 11:38:05 -0500 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 1os58M-0006h8-RH for bug-guix@gnu.org; Mon, 07 Nov 2022 11:38:03 -0500 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 1os58M-00069l-Ii for bug-guix@gnu.org; Mon, 07 Nov 2022 11:38:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1os58M-0007Nt-Cv for bug-guix@gnu.org; Mon, 07 Nov 2022 11:38:02 -0500 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: Mon, 07 Nov 2022 16:38: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: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 58732@debbugs.gnu.org Received: via spool by 58732-submit@debbugs.gnu.org id=B58732.166783905728350 (code B ref 58732); Mon, 07 Nov 2022 16:38:02 +0000 Received: (at 58732) by debbugs.gnu.org; 7 Nov 2022 16:37:37 +0000 Received: from localhost ([127.0.0.1]:35202 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1os57x-0007NC-Dr for submit@debbugs.gnu.org; Mon, 07 Nov 2022 11:37:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48692) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1os57v-0007My-9I for 58732@debbugs.gnu.org; Mon, 07 Nov 2022 11:37:35 -0500 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 1os57p-0003rb-CN; Mon, 07 Nov 2022 11:37:29 -0500 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=yTgxGRS8YCUaMLIg6Bngm5BfBQxQVOZ2Ht4komslPYQ=; b=ZpqV1IsZVrRabtaBPdHD 1W12igFdL6SXeXmAf/RYC1ZJMi2+9tV0WpeJUPRk7eGxR+t6+Qq2/72N7q3v01kjHAyyZMwmQVcZV h7B3DPUcScjtN5pzmX6VL6EhHo+5sb71ld9N240bCzOX/88oBi546fUHB6mu8xlkLWO6G6V5L22BH SXyQ8fpd4c1eGSZIh2OSekT+1R9MtHklLqIwy4Cd2eGTTYxrWCAMcMoqe/CW5llPqexQwKDbEf3A/ hU/Mz6h7ERxcH2QMckzpirMrIEQlGwzZw/xgM5JXQEnsSrVv23gIIpH/34s4qIvM4klV1w40mE5i8 EqIZBHqVaedqYA==; 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 1os57o-000569-I8; Mon, 07 Nov 2022 11:37:28 -0500 From: Mathieu Othacehe References: <87v8oa29ik.fsf@gnu.org> <871qqlwrpy.fsf@gnu.org> <87iljwuwf7.fsf@gnu.org> <871qqkth3g.fsf@gnu.org> <87sfiwm297.fsf@gnu.org> <87iljquc3a.fsf@gnu.org> Date: Mon, 07 Nov 2022 17:37:24 +0100 In-Reply-To: <87iljquc3a.fsf@gnu.org> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Mon, 07 Nov 2022 14:29:45 +0100") Message-ID: <8735auwwjf.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" 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: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: 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=1667839124; 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: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=yTgxGRS8YCUaMLIg6Bngm5BfBQxQVOZ2Ht4komslPYQ=; b=mGAh0mNXQj7yd9vCkFzHS/xeRGfz5CfySmq2Bqd2TSvP3MkYQkfIfTzP/VCLnV2SxPW6iQ fV+j+Rl9xRgnrhfrxIDhN520lBxpsCWszTUR6cNucQZsMptJr34oqJip7geOG3KPJwD6tz OtVDx15HFRHzloR9sq0XlxhbbFBHLDS5EaFxPmfQJ4xB+N6VmHsGoNkbHeOXH2GmxiC4DO 0GjZg5jA4jHg6vja2z+7p8CjKjW7QXTk/3jXNIE6U5wuN+1fU5jNw51q9boPLBJz601OyM +fiTMZ7eLRvn8vrs3gFCPZ4s1NFxNo2Ar01QX4+UmjH/sHZPktP1gOSRXZJmdQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1667839124; a=rsa-sha256; cv=none; b=FUtgQgv3PfOjSnLxiv6OXfDXfSUFCP30p86peS113PGb5Ucwc0c34fm1IR8fosLIpty+ln KbT7Cj8KpjKNNaZZvqEkIZVQEdK4S3ixz/MaqxvI3cgZ6hUTWAaC1BFSU4hBL/07Jywk7n Oc11KrWUnWikoo+uOX2FSDaNVIvGhCYRgW6TC3Kwv+A5/3ldh1qfKYF2D+Z81djI3xAZwm wiEQtl1k/T6TeuOot51wbyAATYiP+ti9cETSpRt2SltWzDi+2MTtcN8QKS77WwKl+H3LCK r4yGgqk2xWwws3QqSnAYwUgCBF64rlzGXXNKQgik4e71QvawtU+pjObab4iDzA== 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=ZpqV1IsZ; 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: -5.11 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=ZpqV1IsZ; 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: EA49217498 X-Spam-Score: -5.11 X-Migadu-Scanner: scn0.migadu.com X-TUID: Vx3OTkX4uArb --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hola, > Finalizers are set on pointer objects, so they=E2=80=99re invoked when the > pointer object goes out of scope. But: > > (eq? (make-pointer 123) (make-pointer 123)) > =3D> #f I agree, but somehow this works: --8<---------------cut here---------------start------------->8--- scheme@(guile-user)> ,use (parted) scheme@(guile-user)> (eq? (get-device "/tmp/test.img") (get-device "/tmp/te= st.img")) $3 =3D #t --8<---------------cut here---------------end--------------->8--- denoting that the "pointer->device!" procedure is working correctly and the underlying pointer object returned by pointer->procedure is the same. > So a possible mistake is to add one finalizer on each pointer object and > have several pointer objects aliasing the same C object; that=E2=80=99s h= ow you > can get the same =E2=80=9Cfree=E2=80=9D function called several times on = the same C > object. I don't think that what's happening. I have monitored closely the %devices weak hash table and it never exceeds the total device count. We have multiple finalizers registered for the same C pointer but that's because the weak hash table may be cleaned by (gc) calls, leaving the opportunity for multiple finalizers registration on the same C pointer. I attached a reproducer that exposes the double free issue. --8<---------------cut here---------------start------------->8--- sudo -E guile ~/tmp/parted-bug.scm double free or corruption (!prev) Aborted --8<---------------cut here---------------end--------------->8--- We could save up somewhere which pointers have registered finalizers but that would prevent the devices garbage collection, in the same way as if %device was a plain hash table and not a weak one. That could well be a solution, as I cannot see at the moment how we could preserve this mechanism and avoid multiple finalization. Thanks, Mathieu --=-=-= Content-Type: application/octet-stream Content-Disposition: attachment; filename=parted-bug.scm Content-Transfer-Encoding: base64 KHVzZS1tb2R1bGVzIChwYXJ0ZWQpKQoKKGRlZmluZSAocHJvYmUpCiAgKHByb2JlLWFsbC1kZXZp Y2VzISkKICAoZ2V0LWRldmljZSAiL3RtcC90ZXN0LmltZyIpCiAgKGRldmljZXMpCiAgMSkKCihk ZWZpbmUgKGEpCiAgKHByb2JlKQogIChwcm9iZSkKICAocHJvYmUpCgogIChsZXQgbG9vcCAoKGkg MCkpCiAgICAod2hlbiAoPCBpIDUpCiAgICAgIChzbGVlcCAxKQogICAgICAoZ2MpCiAgICAgIChn YykKICAgICAgKHByb2JlKQogICAgICAoZ2MpCiAgICAgIChsb29wICgrIDEgaSkpKSkpCgooYSkK KHNsZWVwIDQpCihnYykKKGdjKQooZ2MpCg== --=-=-=--