Error in call to generic function while method being redefined
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
New
|
Undecided
|
Unassigned |
Bug Description
Although CLOS/MOP and concurrency may not be fully supported, the PCL code is doing some attempts to prevent race conditions. The attached example shows that this is not enough: A generic function has two methods. When one of the methods is redefined, a concurrent call to the generic function from another thread may generate an error.
Note that the error is only transient. Calling the generic function after the method redefinition completes will yield the expected results. (But see https:/
sbcl --load /home/vossi/
This is SBCL 1.4.5, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://
SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
#<TYPE-ERROR expected-type: (INTEGER 1 461168601842738
*
uname -a
Linux si2l 4.4.92-31-default #1 SMP Sun Oct 22 06:56:24 UTC 2017 (1d80e8a) x86_64 x86_64 x86_64 GNU/Linux
*features* =>
(:64-BIT :64-BIT-REGISTERS :ALIEN-CALLBACKS :ANSI-CL :ASH-RIGHT-VOPS
:C-STACK-
:COMPARE-
:FP-AND-
:IMMOBILE-SPACE :INLINE-CONSTANTS :INTEGER-EQL-VOP :LARGEFILE :LINKAGE-TABLE
:LINUX :LITTLE-ENDIAN :MEMORY-
:OS-PROVIDES-
:OS-PROVIDES-
:OS-PROVIDES-
:RAW-SIGNED-WORD :RELOCATABLE-HEAP :SB-DOC :SB-EVAL :SB-FUTEX :SB-LDB
:SB-PACKAGE-LOCKS :SB-SIMD-PACK :SB-SOURCE-
:SBCL :STACK-
:STACK-
:STACK-
:UNDEFINED-
description: | updated |
Are you sure this is a duplicate of https:/ /bugs.launchpad .net/bugs/ 1153309? That one seems to have a problem with typep after a single class definition. The bug described here is in PCL:
(%MAKE-CACHE :KEY-COUNT 0 ...) violates the structure definition of cache, with
0: (SB-PCL::MAKE-CACHE :KEY-COUNT 0 :VALUE T :SIZE 2) :MAKE-CONSTANT- VALUE-DFUN #<STANDARD- GENERIC- FUNCTION COMMON-LISP-USER::F (2)> NIL) :CHECKING- MISS #<STANDARD- GENERIC- FUNCTION COMMON-LISP-USER::F (2)> (NIL) #<SB-PCL::CHECKING {1001DC84F3}>)
1: (SB-PCL:
2: (SB-PCL:
3: ((LAMBDA NIL :IN TEST-METHOD))
when you run :
(defun test-method (&key (callers 1)) sb-thread: make-thread
(handler- bind ((error
( lambda (error*)
(print- backtrace)
(setf error error*))))
(eq (f i) i)))
(let ((i (make-instance 'c))
(error nil))
(dotimes (i callers)
(
(lambda ()
(loop
(f nil))
(when error (return)))
:name (format nil "Caller"))))
(loop
(defmethod f ((x c)) x)
(when error (return)))
(assert (and (eq (f nil) t)
(print error)))