From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mathieu Othacehe Subject: bug#36402: installation error Date: Wed, 04 Sep 2019 14:31:35 +0200 Message-ID: <87imq8tf88.fsf@gmail.com> References: <87lfxmu47j.fsf@gnu.org> <878sr989br.fsf@gmail.com> <87a7bnaj0b.fsf@gnu.org> <87imqbgh71.fsf@gmail.com> <87woepyc7d.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:48217) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5USD-0001mP-HP for bug-guix@gnu.org; Wed, 04 Sep 2019 08:32:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5USC-0005Yl-C8 for bug-guix@gnu.org; Wed, 04 Sep 2019 08:32:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:52146) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i5USC-0005Ya-8A for bug-guix@gnu.org; Wed, 04 Sep 2019 08:32:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1i5USC-0004oq-2Y for bug-guix@gnu.org; Wed, 04 Sep 2019 08:32:04 -0400 Sender: "Debbugs-submit" Resent-Message-ID: In-reply-to: <87woepyc7d.fsf@gnu.org> List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 36402@debbugs.gnu.org, Juan Hey Ludo, > Please share whatever you gather before you get depressed. ;-) Thanks a lot for your help, it was really useful! I used valgrind a lot to understand what was happening. Ok so here's a little summary: * Using ped_device_get Parted returns new devices. It may return already existing devices if the given path is already known. Users are responsible for their destruction calling ped_device_destroy. * Using ped_disk_new Parted returns new disks from devices. Users are responsible for their destruction calling ped_disk_destroy. * A disk contains partitions. A user can remove partitions without deleting them. It is also possible to delete them calling ped_partition_destroy. On disk destruction, all the partitions associated are destroyed. Here's how memory is managed in Guile-Parted: * ped_device_destroy is set a finalizer for device pointers. * ped_disk_destroy is set a finalizer for disk pointers. Device object associated to disks are recorded in a weak key hash table, to ensure that the lifetime of a disk is shorted than that of its device. * No finalizer is set for partition pointers. However, disk associated to partitions are recorded in a weak key hash table, to ensure that the lifetime of a partition is shorter that that of its disk. The user can access ped_disk_remove_partition function from Parted but cannot acces ped_partition_destroy function. Partition destruction is done by Parted of disk destruction. And here is what was going wrong: ped_device_get and ped_device_get_next can return pointers to already existing device object. So set-pointer-finalizer! was possibly called multiple times on the same device pointer, resulting in calling ped_device_destroy multiple times on the same device pointer. To prevent that, I created a weak value hash table to make sure that one object maps to exactly one device pointer, and that the pointer finalizer is set only once. See commit b35839b. I also added (gc) calls at various locations in the tests in commit 728fd01. WDYT? Thanks, Mathieu