GET-CAS-EXPANSION of SYMBOL-VALUE buggy for quoted symbol

Bug #1098355 reported by Douglas Katzman on 2013-01-10
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Undecided
Unassigned

Bug Description

The DEFINE-CAS-EXPANDER in 'late-cas.lisp' has an optimization that goes awry.
Assume that the symbol FROB has not been proclaimed special or global.

(get-cas-expansion '(symbol-value 'frob)) =>
NIL
NIL
#:OLD632
#:NEW633
(LOCALLY
 (DECLARE (SYMBOL NIL))
 (SB-INT:ABOUT-TO-MODIFY-SYMBOL-VALUE NIL 'COMPARE-AND-SWAP #:NEW633)
 (SB-KERNEL:%COMPARE-AND-SWAP-SYMBOL-VALUE NIL #:OLD632 #:NEW633))
(SYMBOL-GLOBAL-VALUE 'FROB)

Problems illustrated:
1a. The type-check eschews use of (THE <type> new), deferring to ABOUT-TO-MODIFY, but passes NIL instead of 'FROB
  b. The update form passes NIL to %COMPARE-AND-SWAP. (These are the same problem obviously)
2. The volatile read uses SYMBOL-GLOBAL-VALUE but that's not right because CAS swaps the dynamic binding per this example:

* (defvar x "hi")
* (progn (let ((x 9)) (print (cas (symbol-value 'x) 9 12)) (print x)) x)
prints 9, 12, "hi"

Compare to otherwise correct expansion, barring the last return value, for a non-constant symbol:
* (get-cas-expansion '(symbol-value x)) =>
(#:X637)
(X)
#:OLD638
#:NEW639
(LOCALLY
 (DECLARE (SYMBOL #:X637))
 (SB-INT:ABOUT-TO-MODIFY-SYMBOL-VALUE #:X637 'COMPARE-AND-SWAP #:NEW639)
 (SB-KERNEL:%COMPARE-AND-SWAP-SYMBOL-VALUE #:X637 #:OLD638 #:NEW639))
(SYMBOL-GLOBAL-VALUE #:X637)

Tested in SBCL 1.1.3.3-c8fedad

Stas Boukarev (stassats) wrote :

In fa52f5ce506a4df5fa6b493dd33e1feab874f4a9.

Changed in sbcl:
status: New → Fix Committed
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers