From: "Ludovic Courtès" <ludo@gnu.org>
To: Mathieu Othacehe <othacehe@gnu.org>
Cc: 58732@debbugs.gnu.org
Subject: bug#58732: installer: finalizers & device destroy segfault
Date: Thu, 03 Nov 2022 12:25:39 +0100 [thread overview]
Message-ID: <871qqkth3g.fsf@gnu.org> (raw)
In-Reply-To: <87iljwuwf7.fsf@gnu.org> (Mathieu Othacehe's message of "Thu, 03 Nov 2022 12:09:16 +0100")
Hi!
Mathieu Othacehe <othacehe@gnu.org> skribis:
>> ‘pointer->device!’ attempts to do that but I think it’s 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 <device> records to the
> Guile-Parted users so my assumption is that when <device> goes out of
> scope, the pointer it wraps can be freed, but I'm maybe missing
> something?
Hmm you’re right (and yes it’s the same as ‘define-wrapped-pointer-type’
does). So that should be fine.
> Regarding object lifetime, I wrote a small memo in 2019 here:
> https://issues.guix.gnu.org/36402#11.
Nice, though it does feel like we’re running in circles. :-)
> 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".
OK.
Another thing to keep in mind: finalizers run in a separate thread, so
finalization can happen concurrently. That can be problematic is there
is shared global state in the library that’s being access when an
benign-looking free function is called.
Could you show the backtrace of the other threads as well, preferably
with debugging info?
Thanks,
Ludo’.
next prev parent reply other threads:[~2022-11-03 11:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-23 9:07 bug#58732: installer: finalizers & device destroy segfault Mathieu Othacehe
2022-11-02 10:55 ` Ludovic Courtès
2022-11-03 11:09 ` Mathieu Othacehe
2022-11-03 11:25 ` Ludovic Courtès [this message]
2022-11-06 17:17 ` Mathieu Othacehe
2022-11-07 13:29 ` Ludovic Courtès
2022-11-07 16:37 ` Mathieu Othacehe
2022-11-09 15:25 ` Mathieu Othacehe
2022-11-10 11:42 ` Ludovic Courtès
2022-11-10 12:29 ` Mathieu Othacehe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871qqkth3g.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=58732@debbugs.gnu.org \
--cc=othacehe@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).