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: Wed, 02 Nov 2022 11:55:37 +0100 [thread overview]
Message-ID: <871qqlwrpy.fsf@gnu.org> (raw)
In-Reply-To: <87v8oa29ik.fsf@gnu.org> (Mathieu Othacehe's message of "Sun, 23 Oct 2022 11:07:31 +0200")
Hi,
Mathieu Othacehe <othacehe@gnu.org> 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—e.g., with
‘pointer->device’. If several C functions return a pointer P, you
must make sure to return always the same wrapper and not create a
new one.
‘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.
‘define-wrapped-pointer-type’ in Guile is meant to help with these
things (info "(guile) Void Pointers and Byte Access"). We can’t
use it directly here because we’re using bytestructures and all
that.
2. Scheme wrappers must mirror the aggregation relations of the C
objects they wrap.
For instance, let’s say a PedDisk aggregates PedPartition
objects—i.e., that PedDisk “owns” them and outlives them. Then the
Scheme <disk> wrappers must outlive the Scheme <partition> wrappers
too, so that we don’t end up calling partition finalizers while the
disk that owns them is still alive. This is done using a weak-key
hash table keyed by <disk> objects in this case and populated
anytime a <disk> getter returns a <partition>. (See for example
‘%commit-owners’ in Guile-Git.)
I think we should audit Guile-Parted with these issues in mind.
WDYT?
Ludo’.
next prev parent reply other threads:[~2022-11-02 10:56 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 [this message]
2022-11-03 11:09 ` Mathieu Othacehe
2022-11-03 11:25 ` Ludovic Courtès
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871qqlwrpy.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 external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.