From dd9f2ab664c9d6d7546d5f403bda5157fc4b960b Mon Sep 17 00:00:00 2001 From: Nikodemus Siivola Date: Thu, 12 May 2011 10:42:20 +0000 Subject: [PATCH] 1.0.48.14: more conservative global variable conversion Based on patch by Roman Marynchak. Fixes lp#722734. * Modify IR1-CONVERT-VAR to emit SYMBOL-VALUE wrapper for all global variables except those which are ALWAYS-BOUND. * Modify IR1-STEP-FORM-P to return false for SYMBOL-VALUE with constant argument, now that virtually all global variables are accessed with a function call (which gets converted via a VOP, so the final machine code remains the same.) --- NEWS | 4 ++++ src/compiler/ir1tran.lisp | 27 +++++++++++++++++---------- tests/compiler.pure.lisp | 8 ++++++++ version.lisp-expr | 2 +- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/NEWS b/NEWS index 5a9955c..353fe71 100644 --- a/NEWS +++ b/NEWS @@ -16,6 +16,10 @@ changes relative to sbcl-1.0.48: * bug fix: blocking reads from FIFOs created by RUN-PROGRAM were uninterruptible, as well as blocking reads from socket streams created with for which :SERVE-EVENTS NIL. (regression from 1.0.42.43) + * bug fix: SET-SYNTAX-FROM-CHAR now removes dispatch-macro character syntax + from the to-char if the from-char is not a dispatch-macro character. + * bug fix: references to undefined variables in function calls that are + optimized away now signal a runtime error. (lp#722734) changes in sbcl-1.0.48 relative to sbcl-1.0.47: * incompatible change: SB!KERNEL:INSTANCE-LAMBDA, deprecated for over five diff --git a/src/compiler/ir1tran.lisp b/src/compiler/ir1tran.lisp index 3ad34a6..81b68f7 100644 --- a/src/compiler/ir1tran.lisp +++ b/src/compiler/ir1tran.lisp @@ -654,10 +654,11 @@ (defun ir1-convert-var (start next result name) (declare (type ctran start next) (type (or lvar null) result) (symbol name)) (let ((var (or (lexenv-find name vars) (find-free-var name)))) - (if (and (global-var-p var) (not result)) - ;; KLUDGE: If the reference is dead, convert using SYMBOL-VALUE - ;; which is not flushable, so that unbound dead variables signal - ;; an error (bug 412). + (if (and (global-var-p var) (not (info :variable :always-bound name))) + ;; KLUDGE: If the variable may be unbound, convert using SYMBOL-VALUE + ;; which is not flushable, so that unbound dead variables signal an + ;; error (bug 412, lp#722734): checking for null RESULT is not enough, + ;; since variables can become dead due to later optimizations. (ir1-convert start next result (if (eq (global-var-kind var) :global) `(symbol-global-value ',name) @@ -948,12 +949,18 @@ ;;; instrumentation for? (defun step-form-p (form) (flet ((step-symbol-p (symbol) - (not (member (symbol-package symbol) - (load-time-value - ;; KLUDGE: packages we're not interested in - ;; stepping. - (mapcar #'find-package '(sb!c sb!int sb!impl - sb!kernel sb!pcl))))))) + (and (not (member (symbol-package symbol) + (load-time-value + ;; KLUDGE: packages we're not interested in + ;; stepping. + (mapcar #'find-package '(sb!c sb!int sb!impl + sb!kernel sb!pcl))))) + ;; Consistent treatment of *FOO* vs (SYMBOL-VALUE '*FOO*): + ;; we insert calls to SYMBOL-VALUE for most non-lexical + ;; variable references in order to avoid them being elided + ;; if the value is unused. + (or (not (member symbol '(symbol-value symbol-global-value))) + (not (constantp (second form))))))) (and *allow-instrumenting* (policy *lexenv* (= insert-step-conditions 3)) (listp form) diff --git a/tests/compiler.pure.lisp b/tests/compiler.pure.lisp index f6dcabf..3ff8d01 100644 --- a/tests/compiler.pure.lisp +++ b/tests/compiler.pure.lisp @@ -3874,3 +3874,11 @@ (nconc cycle cycle) (compile nil `(lambda (x) (member x ',cycle))))) + +(with-test (:name :bug-722734) + (assert (raises-error? + (funcall (compile + nil + '(lambda () + (eql (make-array 6) + (list unbound-variable-1 unbound-variable-2)))))))) diff --git a/version.lisp-expr b/version.lisp-expr index b03ad4f..50dfbdf 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -20,4 +20,4 @@ ;;; checkins which aren't released. (And occasionally for internal ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"1.0.48.13" +"1.0.48.14" -- 1.7.10.4