sb-kernel::%type-union stack exhaustion on bad defun

Bug #2038980 reported by Richard Holcombe
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Fix Committed
Undecided
Unassigned

Bug Description

The following code does not drop me into the debugger in sbcl2.3.6

(defun check(expr &key predicate)
  (if predicate
      (list (check expr) predicate)
      (if (atom expr) t
   (check (first expr)))))

(defmacro ucheck(expr predicate)
  (check expr :predicate predicate))

(defconstant +comparisonops+ `(,#'< = ,#'= ,#'eql ,#'equalp))

(defun es() (ucheck 5 (member w +comparisonops+)))

but in versions 2.3.7 through 2.3.9 I get:

 CHECK
* UCHECK
* +COMPARISONOPS+
* INFO: Control stack guard page unprotected
Control stack guard page temporarily disabled: proceed with caution

debugger invoked on a SB-KERNEL::CONTROL-STACK-EXHAUSTED in thread
#<THREAD tid=2155644 "main thread" RUNNING {10044A00A3}>:
  Control stack exhausted (no more space for function call frames).
This is probably due to heavily nested or infinitely recursive function
calls, or a tail call that SBCL cannot or has not optimized away.

PROCEED WITH CAUTION.

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [ABORT] Exit debugger, returning to top level.

(SB-KERNEL::CONTROL-STACK-EXHAUSTED-ERROR)
0]

Looking through the backtrace I see a lot of:
1079: (SB-KERNEL:TYPE-UNION #<SB-KERNEL:CONS-TYPE (CONS (AND (NOT (FUNCTION (NUMBER T) (VALUES BOOLEAN . #1=#))) (FUNCTION (T T) (VALUES BOOLEAN . #1#)) (NOT (FUNCTION (NUMBER &REST T) (VALUES BOOLEAN . #1#)))) LIST)> #<SB-KERNEL:CONS-TYPE (CONS (FUNCTION (NUMBER T) (VALUES BOOLEAN &OPTIONAL)) LIST)> #<SB-KERNEL:CONS-TYPE (CONS (OR (MEMBER =) (AND (NOT (FUNCTION # #)) FUNCTION)) CONS)>) [more]
1080: (SB-KERNEL::%TYPE-UNION2 #<SB-KERNEL:CONS-TYPE (CONS (OR (FUNCTION (NUMBER T) (VALUES BOOLEAN . #1=(&OPTIONAL))) (AND (NOT (FUNCTION # #)) (FUNCTION (T T) (VALUES BOOLEAN . #1#)) (NOT (FUNCTION # #)))) LIST)> #<SB-KERNEL:CONS-TYPE (CONS (OR (MEMBER =) (AND (NOT (FUNCTION # #)) FUNCTION)) CONS)>)
1081: (SB-KERNEL::TYPE-UNION2 #<SB-KERNEL:CONS-TYPE (CONS (OR (FUNCTION (NUMBER T) (VALUES BOOLEAN . #1=(&OPTIONAL))) (AND (NOT (FUNCTION # #)) (FUNCTION (T T) (VALUES BOOLEAN . #1#)) (NOT (FUNCTION # #)))) LIST)> #<SB-KERNEL:CONS-TYPE (CONS (OR (MEMBER =) (AND (NOT (FUNCTION # #)) FUNCTION)) CONS)>)
1082: (SB-KERNEL::SIMPLIFY-UNIONS (#<SB-KERNEL:CONS-TYPE (CONS (OR (FUNCTION (NUMBER T) (VALUES BOOLEAN &OPTIONAL)) (AND (NOT #) (FUNCTION # #) (NOT #))) LIST)> #<SB-KERNEL:CONS-TYPE (CONS (OR (MEMBER =) (AND (NOT #) FUNCTION)) CONS)>))
1083: (SB-KERNEL::%TYPE-UNION (#<SB-KERNEL:CONS-TYPE (CONS (AND (NOT (FUNCTION # #)) (FUNCTION (T T) (VALUES BOOLEAN . #1=#)) (NOT (FUNCTION # #))) LIST)> #<SB-KERNEL:CONS-TYPE (CONS (FUNCTION (NUMBER T) (VALUES BOOLEAN . #1#)) LIST)> #<SB-KERNEL:CONS-TYPE (CONS (OR (MEMBER =) (AND (NOT #) FUNCTION)) CONS)>))

uname -a gives:
Linux papias 6.2.0-33-generic #33~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep 7 10:33:52 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

I understand the above code is clearly buggy, but I don't think sbcl should exhaust the stack in this case.

Stas Boukarev (stassats)
Changed in sbcl:
status: New → Incomplete
status: Incomplete → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.