--- Begin Message ---
Subject: |
Local variables reclaimed early vs. finalizers |
Date: |
Fri, 14 Apr 2017 23:56:50 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) |
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’.
--- End Message ---
--- Begin Message ---
Subject: |
Re: bug#26503: Local variables reclaimed early vs. finalizers |
Date: |
Wed, 19 Apr 2017 14:23:59 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) |
On Wed 19 Apr 2017 11:50, address@hidden (Ludovic Courtès) writes:
> I need to chew a bit more on this, but the conclusion is probably that
> my expectations were incorrect, indeed. :-)
OK I close this bug in the meantime then :) Feel free to reopen if
there is a thing to do!
Andy
--- End Message ---