Summary
Inconsistency when calling set-finalizer! multiple times on the same object
Metadata
- Id: 1e3bcf28bf45dca75d609f85eef7cca3fe0caa9d
- Trac id: 447
- Type: defect
- Reporter: syn
- Owner:
- Cc:
- Status: closed
- Component: unknown
- Estimated difficulty:
- Resolution: fixed
- Priority: major
- Milestone: 4.9.0
- Version: 4.6.x
- Changetime: 2012-09-24 21:47:48 UTC
- Created: 2010-12-09 22:51:21 UTC
- Keywords:
Description
The following program prints "b" when interpreted and "ba" when compiled:
(define x (list 1)) (set-finalizer! x (lambda (x) (display 'a))) (set-finalizer! x (lambda (x) (display 'b))) (set! x #f)
I am not sure whether replacing the existing finalizer or appending another finalizer makes more sense. However, it would probably be better if both cases behaved the same.
Changes and comments
[2010-12-10 20:43:44 UTC] zbigniew wrote:
Weird. I increased your finalizers to 3 and added a (gc #t) to the end as well. Both cases look like they are behaving strangely.
Compiled:
;; (gc #t) [debug] running 1 finalizers (2 live, 3 allocated) ... c[debug] running 1 finalizers (1 live, 3 allocated) ... b[debug] running 1 finalizers (0 live, 3 allocated) ... ;; program end [debug] forcing finalizers... a[debug] application terminated normally
Interpreted (csi -script):
;; (gc #t) [debug] running 1 finalizers (2 live, 3 allocated) ... ;; program end [debug] forcing finalizers... c[debug] application terminated normally
[2010-12-11 13:24:56 UTC] felix changed status from new to closed
[2010-12-11 13:24:56 UTC] felix set resolution to fixed
[2010-12-11 13:24:56 UTC] felix wrote:
This should be fixed now (experimental). The code that walked the finalizer list checks for a finalized object being not forwarded into the new heap area on GC. Previously it marked the object, hiding the "non-forwarded" status for later finalizers for the same object in the finalizer list, which would then never be run. The list is now walked twice, once for checking, and once for marking. GC frequency and the location of objects in memory influence strongly how and when finalizers are checked and executed.
I have tried to improve the documentation.
[2010-12-11 16:08:29 UTC] syn wrote:
Works like a charm, thanks a lot :-) The docs are clear to me now!
[2011-06-01 09:00:41 UTC] felix changed milestone from 4.7.0 to 4.8.0
[2011-06-01 09:00:41 UTC] felix wrote:
Milestone 4.7.0 deleted
[2012-09-24 21:47:48 UTC] felix changed milestone from 4.8.0 to 4.9.0
[2012-09-24 21:47:48 UTC] felix wrote:
Milestone 4.8.0 deleted