Local functions definitions and calls cause "The value NIL is not of type SB-C::CLEANUP."

Bug #1416704 reported by Jan Moringen on 2015-01-31
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
High
Unassigned

Bug Description

What did I do?
Compile a file containing (reduced from clpython output):
(funcall
 (flet ((whoop (v)
          (declare (ignore v))
          (let ((if-stmt-k2133
                 (flet ((fez (v)
                          (declare (ignore v))
                          (funcall (flet ((foo (v) (declare (ignore v))))
                                     #'foo)
                                   nil)))
                   #'fez)))
            (if (py-val->lisp-bool nil)
                (funcall (flet ((bar (v) (declare (ignore v))))
                           #'bar)
                         nil)
                (funcall if-stmt-k2133 nil)))))
   #'whoop)
 nil)

What did I expect to happen?
The from should be compiled.

What happens instead?
During compilation, an error is signaled:
Unhandled TYPE-ERROR in thread #<SB-THREAD:THREAD "main thread" RUNNING
                                  {B659591}>:
  The value NIL is not of type SB-C::CLEANUP.

Backtrace for: #<SB-THREAD:THREAD "main thread" RUNNING {B659591}>
0: (SB-C::EMIT-CLEANUPS #<SB-C::CBLOCK 6 :START c1 {B6711B9}> #<SB-C::CBLOCK 3 :START c2 {B6733E1}>)
1: (SB-C::FIND-CLEANUP-POINTS #<SB-C:COMPONENT :NAME "FUNCALL (FLET (#) (FUNCTION WHOOP))" {B677F51}>)
2: (SB-C::PHYSENV-ANALYZE #<SB-C:COMPONENT :NAME "FUNCALL (FLET (#) (FUNCTION WHOOP))" {B677F51}>)
3: (SB-C::COMPILE-COMPONENT #<SB-C:COMPONENT :NAME "FUNCALL (FLET (#) (FUNCTION WHOOP))" {B677F51}>)
4: (SB-C::%COMPILE (LAMBDA NIL (PROGN (FLET ((WHOOP # # #)) (FUNCTION WHOOP)))) #<SB-C::CORE-OBJECT > :NAME NIL :PATH (SB-C::ORIGINAL-SOURCE-START 0 0))
5: ((FLET #:WITHOUT-INTERRUPTS-BODY-676 :IN SB-THREAD::CALL-WITH-RECURSIVE-LOCK))
6: (SB-THREAD::CALL-WITH-RECURSIVE-LOCK #<CLOSURE (FLET SB-THREAD::WITH-RECURSIVE-LOCK-THUNK :IN SB-C::ACTUALLY-COMPILE) {A783967D}> #<SB-THREAD:MUTEX "World Lock" owner: #<SB-THREAD:THREAD "main thread" RUNNING {B659591}>> T NIL)
7: ((LAMBDA NIL :IN SB-C::ACTUALLY-COMPILE))
8: ((FLET SB-C::WITH-IT :IN SB-C::%WITH-COMPILATION-UNIT))
9: (SB-C::ACTUALLY-COMPILE NIL (LAMBDA NIL (PROGN (FLET ((WHOOP # # #)) (FUNCTION WHOOP)))) #<NULL-LEXENV> #<SB-C::SOURCE-INFO > 0 NIL)
10: (SB-C:COMPILE-IN-LEXENV NIL (LAMBDA NIL (PROGN (FLET ((WHOOP # # #)) (FUNCTION WHOOP)))) #<NULL-LEXENV> #<SB-C::SOURCE-INFO > 0 NIL)
11: (SB-IMPL::%SIMPLE-EVAL (FLET ((WHOOP (V) (DECLARE (IGNORE V)) (LET (#) (IF # # #)))) (FUNCTION WHOOP)) #<NULL-LEXENV>)
12: (SB-INT:SIMPLE-EVAL-IN-LEXENV (FLET ((WHOOP (V) (DECLARE (IGNORE V)) (LET (#) (IF # # #)))) (FUNCTION WHOOP)) #<NULL-LEXENV>)
13: (SB-INT:SIMPLE-EVAL-IN-LEXENV (FUNCALL (FLET ((WHOOP (V) (DECLARE #) (LET # #))) (FUNCTION WHOOP)) NIL) #<NULL-LEXENV>)
14: (EVAL-TLF (FUNCALL (FLET ((WHOOP (V) (DECLARE #) (LET # #))) (FUNCTION WHOOP)) NIL) 0 #<NULL-LEXENV>)
15: ((FLET SB-FASL::EVAL-FORM :IN SB-INT:LOAD-AS-SOURCE) (FUNCALL (FLET ((WHOOP (V) (DECLARE #) (LET # #))) (FUNCTION WHOOP)) NIL) 0)
16: (SB-INT:LOAD-AS-SOURCE #<SB-SYS:FD-STREAM for "file /home/jmoringe/code/cl/SBCL/bug.lisp" {B65A361}> :VERBOSE NIL :PRINT NIL :CONTEXT "loading")
17: ((FLET SB-FASL::LOAD-STREAM :IN LOAD) #<SB-SYS:FD-STREAM for "file /home/jmoringe/code/cl/SBCL/bug.lisp" {B65A361}> NIL)
18: (LOAD #P"/home/jmoringe/code/cl/SBCL/bug.lisp" :VERBOSE NIL :PRINT NIL :IF-DOES-NOT-EXIST T :EXTERNAL-FORMAT :DEFAULT)
19: (SB-IMPL::PROCESS-EVAL/LOAD-OPTIONS ((:LOAD . "/home/jmoringe/code/cl/SBCL/bug.lisp")))
20: (SB-IMPL::TOPLEVEL-INIT)
21: ((FLET #:WITHOUT-INTERRUPTS-BODY-77 :IN SAVE-LISP-AND-DIE))
22: ((LABELS SB-IMPL::RESTART-LISP :IN SAVE-LISP-AND-DIE))

SBCL version
85bdc4b

*FEATURES*
(:ALIEN-CALLBACKS :ANSI-CL :ASH-RIGHT-VOPS :C-STACK-IS-CONTROL-STACK
 :COMMON-LISP :COMPARE-AND-SWAP-VOPS :CYCLE-COUNTER :ELF :GENCGC
 :IEEE-FLOATING-POINT :INLINE-CONSTANTS :LARGEFILE :LINKAGE-TABLE :LINUX
 :LITTLE-ENDIAN :MEMORY-BARRIER-VOPS :MULTIPLY-HIGH-VOPS :OS-PROVIDES-BLKSIZE-T
 :OS-PROVIDES-DLADDR :OS-PROVIDES-DLOPEN :OS-PROVIDES-GETPROTOBY-R
 :OS-PROVIDES-POLL :OS-PROVIDES-PUTWC :OS-PROVIDES-SUSECONDS-T
 :PACKAGE-LOCAL-NICKNAMES :RAW-INSTANCE-INIT-VOPS :SB-AFTER-XC-CORE
 :SB-CORE-COMPRESSION :SB-DOC :SB-EVAL :SB-FUTEX :SB-LDB :SB-PACKAGE-LOCKS
 :SB-SOURCE-LOCATIONS :SB-TEST :SB-THREAD :SB-UNICODE :SB-XREF-FOR-INTERNALS
 :SBCL :STACK-ALLOCATABLE-CLOSURES :STACK-ALLOCATABLE-FIXED-OBJECTS
 :STACK-ALLOCATABLE-LISTS :STACK-ALLOCATABLE-VECTORS
 :STACK-GROWS-DOWNWARD-NOT-UPWARD :SYMBOL-INFO-VOPS :UNIX
 :UNWIND-TO-FRAME-AND-CALL-VOP :X86)

Jan Moringen (scymtym) wrote :

Could be related to or a duplicate of https://bugs.launchpad.net/sbcl/+bug/404441.

Jan Moringen (scymtym) wrote :

Further reduction:
(flet ((whoop ()
         (if (> (random 1.0) .5)
             (funcall (flet ((bar ())) #'bar))
             (funcall (flet ((fez ()
                               (funcall (flet ((foo ())) #'foo))))
                        #'fez)))))
  #'whoop)

Changed in sbcl:
status: New → Confirmed
Stas Boukarev (stassats) on 2015-01-31
Changed in sbcl:
importance: Undecided → High
Stas Boukarev (stassats) wrote :

Seems like a simple null check will do. Will commit after the freeze.

Changed in sbcl:
status: Confirmed → In Progress
Stas Boukarev (stassats) wrote :

In ab242b1489d09e144de6efacea2eba359d68b9cb

Changed in sbcl:
status: In Progress → 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.

Other bug subscribers