GNU bug report logs -
#26503
Local variables reclaimed early vs. finalizers
Previous Next
Reported by: ludo <at> gnu.org (Ludovic Courtès)
Date: Fri, 14 Apr 2017 21:58:02 UTC
Severity: normal
Done: Andy Wingo <wingo <at> igalia.com>
Bug is archived. No further changes may be made.
Full log
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hello!
Consider this code:
--8<---------------cut here---------------start------------->8---
(use-modules (system foreign))
(define %table
(make-weak-value-hash-table))
(define %abort
(dynamic-func "abort" (dynamic-link)))
(let ((ptr (make-pointer 123 %abort)))
(display "hello\n")
(gc))
--8<---------------cut here---------------end--------------->8---
Guile is free to collect ‘ptr’ when ‘gc’ is called since it has become
unreachable at that point; that’s what 2.2.0 does, as explained in
‘NEWS’.
However, there’s a finalizer here so collecting ‘ptr’ has an observable
side effect. This side effect makes the semantic change visible: the
“expected” semantics would be that ‘ptr’ is not subject to GC while it’s
in scope.
(In 2.0 the finalizer is not called until ‘ptr’ is no longer in scope.)
I’m not sure this counts as a bug, but it’s certainly a pitfall when
working with finalizers and the FFI.
Thoughts?
Ludo’.
This bug report was last modified 8 years and 120 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.