[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-janitors] #1356: weak-locatives references return #f when it sh
From: |
Chicken Trac |
Subject: |
[Chicken-janitors] #1356: weak-locatives references return #f when it shouldn't |
Date: |
Thu, 23 Mar 2017 19:39:31 -0000 |
#1356: weak-locatives references return #f when it shouldn't
------------------------+-------------------------------
Reporter: kristianlm | Owner:
Type: defect | Status: new
Priority: major | Milestone: 4.13.0
Component: unknown | Version: 4.12.0
Keywords: | Estimated difficulty:
------------------------+-------------------------------
version:
{{{
;; 2015 address@hidden /s/p/a/a/s/ais-sse ➤ csi -version
;;
;; CHICKEN
;; (c) 2008-2017, The CHICKEN Team
;; (c) 2000-2007, Felix L. Winkelmann
;; Version 4.12.0 (rev 6ea24b6)
;; linux-unix-gnu-x86-64 [ 64bit manyargs dload ptables ]
;; compiled 2017-02-19 on yves.more-magic.net (Linux)
}}}
running the program below '''should''' output this:
{{{
;; 2017 address@hidden /s/p/a/a/s/ais-sse ➤ cat weak-test.scm | csi -p
'(read)'
;; (use srfi-18 lolevel)
;; 2017 address@hidden /s/p/a/a/s/ais-sse ➤ csi -s weak-test.scm
;; locking mutex
;; unlocking mutex ...
;; weak locative: #(123)
;; weak locative: #(123)
;; weak locative: #(123)
;; weak locative: #(123)
;; ^C
;; *** user interrupt ***
;;
}}}
Where the locative to REFERENCE is kept alive forever. However, it looses
track of this REFERENCE:
{{{
;;
;; 2016 address@hidden /s/p/a/a/s/ais-sse ➤ csi -s weak-test.scm
;; locking mutex
;; unlocking mutex ...
;; weak locative: #(123)
;; weak locative: #f
;; weak locative: #f
;; weak locative: #f
;; ^C
;; *** user interrupt ***
}}}
There are several ways you can make this program work:
- compile it and run it
- remove the srfi-13 import (it's not used)
- assign the first thread to a top variable
Here's the program in question that doesn't work:
{{{
(use srfi-13 ;; <-- killer import (any import will breaks things, try
srfi-4 too for example)
srfi-18 lolevel)
(define wl #f)
(thread-start!
(lambda ()
(define mutex (make-mutex))
(define cv (make-condition-variable))
(print "locking mutex")
(mutex-lock! mutex)
(let ((REFERENCE (vector 123)))
(set! wl (make-weak-locative REFERENCE))
(print "unlocking mutex ...")
(mutex-unlock! mutex cv)
(print "unlocked!")
(print "DONE (REFERENCE may now be out of scope) " REFERENCE))))
(thread-start!
(lambda ()
(let loop ()
(print "weak locative: " (locative->object wl))
(thread-sleep! 1)
(gc #t)
(loop))))
(thread-sleep! 10)
}}}
--
Ticket URL: <https://bugs.call-cc.org/ticket/1356>
CHICKEN Scheme <https://www.call-cc.org/>
CHICKEN Scheme is a compiler for the Scheme programming language.
- [Chicken-janitors] #1356: weak-locatives references return #f when it shouldn't,
Chicken Trac <=