emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#10668: closed (FFI: ‘ set-pointer-finalizer!’ ove


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#10668: closed (FFI: ‘ set-pointer-finalizer!’ overrides the previous finaliz er)
Date: Fri, 06 Jul 2012 18:32:01 +0000

Your message dated Fri, 06 Jul 2012 20:26:20 +0200
with message-id <address@hidden>
and subject line Re: bug#10668: FFI: ‘set-pointer-finalizer!’ overrides the 
previous finalizer
has caused the debbugs.gnu.org bug report #10668,
regarding FFI: ‘set-pointer-finalizer!’ overrides the previous finalizer
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
10668: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=10668
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: FFI: ‘set-pointer-finalizer!’ overrides the previous finalizer Date: Mon, 30 Jan 2012 23:31:59 +0100 User-agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.90 (gnu/linux)
Hi,

The ‘set-pointer-finalizer!’ procedure is harmful because it erases any
previously set finalizer.

Said finalizer could come from a guardian:

   (define ptr (make-pointer 123))
   (define g (make-guardian))
   (g ptr)
   (set-pointer-finalizer! ptr (dynamic-func "scm_is_pair" (dynamic-link)))
   (set! ptr #f)
   (gc)

   (g)          ;; Should return PTR.
   => #f

or from a weak hash table:

   (define ptr (make-pointer 123))
   (define t (make-weak-value-hash-table))
   (hashq-set! t ptr #t)
   (set-pointer-finalizer! ptr (dynamic-func "scm_is_pair" (dynamic-link)))
   (set! ptr #f)
   (gc)
   (gc)

   (hash-fold alist-cons '() t)
   => ((#<pointer 0x7b> . #t))   ;; Should be the empty list.


There are several ways to fix this:

  1. Deprecate ‘set-pointer-finalizer!’ in favor of guardians, with the
     problem that it would be up to the user to actually call the
     guardians.

  2. Implement ‘set-pointer-finalizer!’ in terms of guardians, with a
     gc-hook to automatically call the guardians and invoke any
     finalizers.

  3. Fix ‘set-pointer-finalizer!’ to honor the previously-set finalizer,
     if any.  This means (a) finding a way to keep previous-finalizer
     info around, and (b) duplicating part of the (hairy) code from
     guardians.c to honor the previous finalizer.

None of these solutions is really pleasant.

Thoughts?

Thanks,
Ludo’.



--- End Message ---
--- Begin Message --- Subject: Re: bug#10668: FFI: ‘set-pointer-finalizer! ’ overrides the previous finalizer Date: Fri, 06 Jul 2012 20:26:20 +0200 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux)
On Mon 30 Jan 2012 23:31, address@hidden (Ludovic Courtès) writes:

> The ‘set-pointer-finalizer!’ procedure is harmful because it erases any
> previously set finalizer.
>
> Said finalizer could come from a guardian:
>
>    (define ptr (make-pointer 123))
>    (define g (make-guardian))
>    (g ptr)
>    (set-pointer-finalizer! ptr (dynamic-func "scm_is_pair" (dynamic-link)))
>    (set! ptr #f)
>    (gc)
>
>    (g)          ;; Should return PTR.
>    => #f

This has worked since 75ba64d6797f5857cc9885eb753126119a8c8b68.

Andy
-- 
http://wingolog.org/


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]