The value NIL is not of type FUNCTION inside SB-PCL::INVOKE-EMF
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
| SBCL |
High
|
Christophe Rhodes |
Bug Description
A TYPE-ERROR is sometimes signaled instead of a PROGRAM-ERROR.
This behavior is intermittent and disappears if I call (test) the second time.
-------
;;;; /tmp/foo.lisp
(defun report-
(format stream "The variable ~S is unbound."
(defclass my-unbound-variable ()
((name :reader my-cell-error-name :initarg :name)))
(defmethod print-object ((condition my-unbound-
(funcall #'report-
(defun test ()
(funcall (lambda () (my-cell-error-name
-------
CL-USER> (lisp-implement
"2.1.0"
CL-USER> (sb-ext:
Basic qualities:
COMPILATION-SPEED = 1
DEBUG = 1
SAFETY = 1
SPACE = 1
SPEED = 1
INHIBIT-WARNINGS = 1
Dependent qualities:
SB-C::CHECK-
SB-C::TYPE-CHECK = 1 -> 3 (full)
SB-C::CHECK-
SB-C::LET-
SB-C:ALIEN-
SB-C:VERIFY-
SB-C::INSERT-
SB-C::RECOGNIZE
SB-C::FLOAT-
SB-C:INSERT-
SB-C::COMPUTE-
SB-C:STORE-
SB-C::PRESERVE-
SB-C::INSERT-
SB-C::STORE-
SB-C:STORE-
SB-C::INSTRUMEN
SB-C::STORE-
SB-KERNEL:
; No value
-------
; compiling file "/tmp/foo.lisp" (written 30 DEC 2020 11:57:41 AM):
; file: /tmp/foo.lisp
; in: DEFUN TEST
; (MY-CELL-ERROR-NAME (MAKE-INSTANCE 'MY-UNBOUND-
;
; caught STYLE-WARNING:
; The function MY-CELL-ERROR-NAME is called with two arguments, but wants exactly one.
;
; compilation unit finished
; caught 1 STYLE-WARNING condition
; wrote /tmp/foo.fasl
; compilation finished in 0:00:00.012
CL-USER> (test)
The value
NIL
is not of type
FUNCTION
[Condition of type TYPE-ERROR]
Restarts:
0: [RETRY] Retry SLIME REPL evaluation request.
1: [*ABORT] Return to SLIME's top level.
2: [ABORT] abort thread (#<THREAD "repl-thread" RUNNING {100FF91EC3}>)
Backtrace:
0: (SB-PCL::INVOKE-EMF 0 (The variable FOO is unbound. NIL))
1: (SB-INT:
2: (EVAL (TEST))
Michał "phoe" Herda (phoe-krk) wrote : | #1 |
Michał "phoe" Herda (phoe-krk) wrote : | #2 |
Further reduced test case:
(defclass foo ()
((name :reader foo-name)))
(defun test ()
(funcall (lambda () (foo-name (make-instance 'foo) nil))))
Michał "phoe" Herda (phoe-krk) wrote : | #3 |
(defun oops (&rest args) (break "Broken: ~S" args))
(defclass foo () ((name :reader foo-name)))
(defun test ()
(funcall (lambda () (foo-name (make-instance 'foo) #'oops))))
-------
CL-USER> (test)
Unhandled memory fault at #x0.
[Condition of type SB-SYS:
Restarts:
0: [RETRY] Retry SLIME REPL evaluation request.
1: [*ABORT] Return to SLIME's top level.
2: [ABORT] abort thread (#<THREAD "repl-thread" RUNNING {100FF91EC3}>)
Backtrace:
0: (SB-PCL::INVOKE-EMF 0 (#<FOO {1011BD20D3}> #<FUNCTION OOPS>))
1: (SB-INT:
2: (EVAL (TEST))
Christophe Rhodes (csr21-cantab) wrote : | #4 |
The confusion in INVOKE-EMF causes a two-arg call to a reader function to attempt to write the first argument at a slot offset of the second. This is... not ideal.
(defun report-
(format stream "The variable ~S is unbound."
(defclass my-unbound-variable ()
((name :reader my-cell-error-name :initarg :name)))
(defmethod print-object ((condition my-unbound-
(funcall #'report-
(defclass zzz ()
((x :initform 1))
(:metaclass sb-mop:
(defun test ()
(let ((zzz (make-instance 'zzz)))
(assert (typep (slot-value zzz 'x) '(integer 1)))
(funcall (lambda () (my-cell-error-name
(assert (typep (slot-value zzz 'x) '(integer 1)))))
Changed in sbcl: | |
importance: | Undecided → High |
status: | New → Confirmed |
status: | Confirmed → Triaged |
assignee: | nobody → Christophe Rhodes (csr21-cantab) |
Christophe Rhodes (csr21-cantab) wrote : | #5 |
fixed in 1543714587bfb53
Changed in sbcl: | |
status: | Triaged → Fix Committed |
Changed in sbcl: | |
status: | Fix Committed → Fix Released |
Oops - this is not a regression, this is an old bug! (Thanks, Krystof.) Reproduced on SBCL 1.4.16 and 2.0.11.
I only did not notice it because I always run SBCL with (OPTIMIZE SAFETY DEBUG), and it took another person who ran the test suite on default settings to notice this failure.