GNU bug report logs -
#58732
installer: finalizers & device destroy segfault
Previous Next
Reported by: Mathieu Othacehe <othacehe <at> gnu.org>
Date: Sun, 23 Oct 2022 09:08:01 UTC
Severity: important
Done: Mathieu Othacehe <othacehe <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Hi,
Mathieu Othacehe <othacehe <at> 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’.
This bug report was last modified 2 years and 195 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.