Steel Bank Common Lisp

Local FTYPE declarations don't ensure their type is a FUNCTION type

Reported by Jean-Philippe Paradis on 2011-03-19
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Medium
Unassigned

Bug Description

What I do:
(flet ((foo ()))
  (declare (ftype non-function-type foo))
  (foo))

What happens:
  failed AVER: (NULL (FUNCTIONAL-ENTRY-FUN LEAF))
This is probably a bug in SBCL itself. (Alternatively, SBCL
might have been corrupted by bad user code, e.g. by an undefined
Lisp operation like (FMAKUNBOUND 'COMPILE), or by stray pointers
from alien code or from unsafe Lisp code; or there might be a
bug in the OS or hardware that SBCL is running on.) If it seems
to be a bug in SBCL itself, the maintainers would like to know
about it. Bug reports are welcome on the SBCL mailing lists,
which you can find at <http://sbcl.sourceforge.net/>.
   [Condition of type SB-INT:BUG]

Restarts:
 0: [RETRY] Retry SLIME REPL evaluation request.
 1: [*ABORT] Return to SLIME's top level.
 2: [TERMINATE-THREAD] Terminate this thread (#<THREAD "repl-thread" RUNNING {B378B41}>)

Backtrace:
  0: (SB-INT:BUG "~@<failed AVER: ~2I~_~A~:>")[:EXTERNAL]
  1: (SB-IMPL::%FAILED-AVER (NULL (SB-C::FUNCTIONAL-ENTRY-FUN SB-C::LEAF)))
  2: (SB-C::DELETE-REF #<SB-C::REF :LEAF # {C2D79D9}>)
  3: (SB-C::CHANGE-REF-LEAF ..)
  4: (SB-C::LOCALL-ANALYZE-FUN-1 #<SB-C::CLAMBDA :%SOURCE-NAME FOO :%DEBUG-NAME (FLET FOO) :KIND NIL :TYPE #<SB-KERNEL:UNKNOWN-TYPE NON-FUNCTION-TYPE> :WHERE-FROM :DEFINED :VARS NIL {C2D1679}>)
  5: ((FLET SB-C::CLOSURE-NEEDING-IR1-ENVIRONMENT-FROM-NODE))
  6: (SB-C::%WITH-IR1-ENVIRONMENT-FROM-NODE #<SB-C:BIND :LAMBDA #> #<CLOSURE (FLET SB-C::CLOSURE-NEEDING-IR1-ENVIRONMENT-FROM-NODE) {C2DAEA5}>)
  7: (SB-C::REFERENCE-ENTRY-POINT #<SB-C::REF :LEAF # {C2D79D9}>)
  8: (SB-C::LOCALL-ANALYZE-FUN-1 #<SB-C::CLAMBDA :%SOURCE-NAME FOO :%DEBUG-NAME (FLET FOO) :KIND NIL :TYPE #<SB-KERNEL:UNKNOWN-TYPE NON-FUNCTION-TYPE> :WHERE-FROM :DEFINED :VARS NIL {C2D1679}>)
  9: (SB-C::LOCALL-ANALYZE-COMPONENT #<SB-C:COMPONENT :NAME (SB-C::INITIAL-COMPONENT #) :REANALYZE T {C2D10F9}>)
 10: (SB-C::LOCALL-ANALYZE-CLAMBDAS-UNTIL-DONE (#<SB-C::CLAMBDA :%SOURCE-NAME SB-C::.ANONYMOUS. :%DEBUG-NAME # :KIND :EXTERNAL :TYPE # :WHERE-FROM :DEFINED :VARS # {C2DA6E9}>))
 11: (SB-C::%COMPILE ..)[:EXTERNAL]
 12: ((LAMBDA ()))
 13: ((FLET SB-THREAD::WITH-RECURSIVE-LOCK-THUNK))
 14: ((FLET #:WITHOUT-INTERRUPTS-BODY-[CALL-WITH-RECURSIVE-LOCK]324))
 15: (SB-THREAD::CALL-WITH-RECURSIVE-LOCK ..)
 16: ((FLET SB-C::WITH-IT))
 17: (SB-C::ACTUALLY-COMPILE ..)
 18: (SB-C:COMPILE-IN-LEXENV ..)
 19: (SB-IMPL::%SIMPLE-EVAL ..)
 20: (SB-INT:SIMPLE-EVAL-IN-LEXENV ..)
 21: (SWANK::EVAL-REGION "\n(flet ((foo ()))\n (declare (ftype non-function-type foo))\n (foo))\n")
 22: ((LAMBDA ()))
 23: (SWANK::TRACK-PACKAGE #<CLOSURE (LAMBDA #) {C2CCAA5}>)
 24: ((LAMBDA ()))
 25: (SWANK::CALL-WITH-RETRY-RESTART "Retry SLIME REPL evaluation request." #<CLOSURE (LAMBDA #) {C2CCA35}>)
 26: ((LAMBDA ()))
 27: (SWANK-BACKEND:CALL-WITH-SYNTAX-HOOKS #<CLOSURE (LAMBDA #) {C2CCA1D}>)
 28: (SWANK::CALL-WITH-BUFFER-SYNTAX NIL #<CLOSURE (LAMBDA #) {C2CCA1D}>)
 29: (SWANK::REPL-EVAL "\n(flet ((foo ()))\n (declare (ftype non-function-type foo))\n (foo))\n")
 30: (SWANK:LISTENER-EVAL "\n(flet ((foo ()))\n (declare (ftype non-function-type foo))\n (foo))\n")
 31: (SB-INT:SIMPLE-EVAL-IN-LEXENV (SWANK:LISTENER-EVAL "\n(flet ((foo ()))\n (declare (ftype non-function-type foo))\n (foo))\n") #<NULL-LEXENV>)
 32: (SWANK:EVAL-FOR-EMACS (SWANK:LISTENER-EVAL "\n(flet ((foo ()))\n (declare (ftype non-function-type foo))\n (foo))\n") "COMMON-LISP-USER" 298)
 33: (SWANK::PROCESS-REQUESTS NIL)
 34: ((LAMBDA ()))
 35: ((LAMBDA ()))
 36: (SWANK-BACKEND::CALL-WITH-BREAK-HOOK #<FUNCTION SWANK:SWANK-DEBUGGER-HOOK> #<CLOSURE (LAMBDA #) {B37A09D}>)
 37: ((FLET SWANK-BACKEND:CALL-WITH-DEBUGGER-HOOK) #<FUNCTION SWANK:SWANK-DEBUGGER-HOOK> #<CLOSURE (LAMBDA #) {B37A09D}>)
 38: (SWANK-BACKEND:CALL-WITH-DEBUGGER-HOOK #<FUNCTION SWANK:SWANK-DEBUGGER-HOOK> #<CLOSURE (LAMBDA #) {B37A09D}>)
 39: ((LAMBDA ()))
 40: (SWANK::CALL-WITH-BINDINGS ((*STANDARD-OUTPUT* . #) (*STANDARD-INPUT* . #) (*TRACE-OUTPUT* . #) (*ERROR-OUTPUT* . #) (*DEBUG-IO* . #) (*QUERY-IO* . #) ...) #<CLOSURE (LAMBDA #) {B37A0AD}>)
 41: ((FLET #:FORM-FUN-[HANDLE-REQUESTS]1558))
 42: (SWANK::HANDLE-REQUESTS #<SWANK::CONNECTION {B9DE299}> NIL)
 43: (SWANK::REPL-LOOP #<SWANK::CONNECTION {B9DE299}>)
 44: ((LAMBDA ()))
 45: (SWANK::CALL-WITH-BINDINGS NIL #<CLOSURE (LAMBDA #) {B37A08D}>)
 46: ((LAMBDA ()))
 47: ((FLET #:WITHOUT-INTERRUPTS-BODY-[BLOCK362]367))
 48: ((FLET SB-THREAD::WITH-MUTEX-THUNK))
 49: ((FLET #:WITHOUT-INTERRUPTS-BODY-[CALL-WITH-MUTEX]300))
 50: (SB-THREAD::CALL-WITH-MUTEX ..)
 51: (SB-THREAD::INITIAL-THREAD-FUNCTION)
 52: ("foreign function: #x8067E5B")
 53: ("foreign function: #x805300D")
 54: ("foreign function: #x805EBE0")
 55: ("foreign function: #xB7FB596E")

What I expected to happen:
The compiler should ensure that a locally declared FTYPE is indeed a FUNCTION type, as DECLAIM already does:

(declaim (ftype non-function-type foo))
error --> "not a function type: NON-FUNCTION-TYPE"

SBCL version: 1.0.42
uname -a: Linux dynamorph 2.6.32-29-generic #58-Ubuntu SMP Fri Feb 11 19:00:09 UTC 2011 i686 GNU/Linux

*features*:
(:SWANK :QUICKLISP :SB-BSD-SOCKETS-ADDRINFO :ASDF2 :ASDF :ANSI-CL :COMMON-LISP
 :SBCL :SB-DOC :SB-TEST :SB-LDB :SB-PACKAGE-LOCKS :SB-UNICODE :SB-EVAL
 :SB-SOURCE-LOCATIONS :IEEE-FLOATING-POINT :X86 :UNIX :ELF :LINUX :SB-THREAD
 :LARGEFILE :GENCGC :STACK-GROWS-DOWNWARD-NOT-UPWARD :C-STACK-IS-CONTROL-STACK
 :COMPARE-AND-SWAP-VOPS :UNWIND-TO-FRAME-AND-CALL-VOP :RAW-INSTANCE-INIT-VOPS
 :STACK-ALLOCATABLE-CLOSURES :STACK-ALLOCATABLE-VECTORS
 :STACK-ALLOCATABLE-LISTS :STACK-ALLOCATABLE-FIXED-OBJECTS :ALIEN-CALLBACKS
 :CYCLE-COUNTER :INLINE-CONSTANTS :MEMORY-BARRIER-VOPS :LINKAGE-TABLE
 :OS-PROVIDES-DLOPEN :OS-PROVIDES-PUTWC :OS-PROVIDES-SUSECONDS-T)

Changed in sbcl:
importance: Undecided → Medium
status: New → Triaged
tags: added: compiler-ir1
tags: added: types
Changed in sbcl:
assignee: nobody → Nikodemus Siivola (nikodemus)
status: Triaged → In Progress
Nikodemus Siivola (nikodemus) wrote :

Fix on https://github.com/nikodemus/SBCL/tree/pending -- comming pending freeze.

Nikodemus Siivola (nikodemus) wrote :

commit aa29ec0354034ea928f56bbedef1edd158a42c79
Author: Nikodemus Siivola <email address hidden>
Date: Wed Aug 17 12:28:29 2011 +0300

    ignore non-function FTYPEs

      Fixes lp#738464.

      Give a style-warning and ignore the bad type.

Changed in sbcl:
assignee: Nikodemus Siivola (nikodemus) → nobody
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