Subject: bug#26503: closed (Re: bug#26503: Local variables reclaimed early vs. finalizers)

From: [email-masked] (GNU bug Tracking System)
Date: Wed, 19 Apr 2017 12:25:02 +0000

Your bug report

#26503: Local variables reclaimed early vs. finalizers

which was filed against the guile package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
26503: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=26503
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#26503: Local variables reclaimed early vs. finalizers
From: Andy Wingo <[email-masked]>
To: [email-masked] (Ludovic Courtès)
Cc: [email-masked]
Date: Wed, 19 Apr 2017 14:23:59 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

On Wed 19 Apr 2017 11:50, [email-masked] (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

Subject: Local variables reclaimed early vs. finalizers
From: [email-masked] (Ludovic Courtès)
To: [email-masked]
Date: Fri, 14 Apr 2017 23:56:50 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

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’.