small recursive function stack overflow crashes sbcl. Windows 8/ 64bit sbcl

Bug #1302866 reported by Rolf Madsen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Fix Released
Undecided
Luís Oliveira

Bug Description

The following piece of code:

(defun req-sqrt(v)
    (sqrt (req-sqrt v)))
(req-sqrt 1.0)
(req-sqrt 1.0)

reliable crashes both sbcl 1.1.8 and 1.1.12 on my setup: windows 8 64 bit with 64 bit sbcl.

actually replacing sqrt with sin or + 1 has same behaviour, possibly any function will do.

On 1.1.12 one might have to try twice.

*features*
(:SWANK :QUICKLISP :ASDF3 :ASDF2 :ASDF :OS-WINDOWS :NON-BASE-CHARS-EXIST-P
 :ASDF-UNICODE :ALIEN-CALLBACKS :ANSI-CL :ASH-RIGHT-VOPS
 :C-STACK-IS-CONTROL-STACK :COMMON-LISP :COMPARE-AND-SWAP-VOPS
 :COMPLEX-FLOAT-VOPS :CYCLE-COUNTER :FLOAT-EQL-VOPS :GENCGC
 :IEEE-FLOATING-POINT :INLINE-CONSTANTS :LINKAGE-TABLE :LITTLE-ENDIAN
 :MEMORY-BARRIER-VOPS :MULTIPLY-HIGH-VOPS :OS-PROVIDES-DLOPEN
 :OS-PROVIDES-PUTWC :PACKAGE-LOCAL-NICKNAMES :RAW-INSTANCE-INIT-VOPS :SB-DOC
 :SB-DYNAMIC-CORE :SB-EVAL :SB-FUTEX :SB-LDB :SB-PACKAGE-LOCKS :SB-QSHOW
 :SB-SAFEPOINT :SB-SAFEPOINT-STRICTLY :SB-SIMD-PACK :SB-SOURCE-LOCATIONS
 :SB-TEST :SB-THREAD :SB-THRUPTION :SB-UNICODE :SB-WTIMER :SBCL
 :STACK-ALLOCATABLE-CLOSURES :STACK-ALLOCATABLE-FIXED-OBJECTS
 :STACK-ALLOCATABLE-LISTS :STACK-ALLOCATABLE-VECTORS
 :STACK-GROWS-DOWNWARD-NOT-UPWARD :UNWIND-TO-FRAME-AND-CALL-VOP :WIN32 :X86-64)

Tags: os-windows
Revision history for this message
Jan Moringen (scymtym) wrote :

> reliable crashes [...]

Can you describe the failure mode in more detail?

> On 1.1.12 one might have to try twice.

What happens in the first try? The expected "Binding stack exhausted. PROCEED WITH CAUTION."?

Running SBCL 1.1.12 under wine (on x86) produces the following:

$ wine sbcl
This is SBCL 1.1.12, an implementation of ANSI Common Lisp.
[...]
* (defun req-sqrt(v)
    (sqrt (req-sqrt v)))
REQ-SQRT
* (req-sqrt 1.0)
err:seh:setup_exception_record stack overflow 1792 bytes in thread 0009 eip 7ef633e8 esp 00540c30 stack 0x540000-0x541000-0x740000

Is this equivalent to what you experience?

tags: added: os-windows
Revision history for this message
Rolf Madsen (rolfrm) wrote :

first of all I should probably note that no optimizations are enabled. im running a new install and just enter what i wrote above. It is installed next to an older 1.1.8 installation, but i dont think they interfer in any way. I have simply installed the .msi from sbcl.org.

I have tested more versions now: 1.1.17 x86 and x86-64. Still same problem.

somehow if i run through slime it crashes the first time always and through cmd.exe it always crashes the second time.

>Can you describe the failure mode in more detail?

sbcl.exe exits. Windows pops up a messagebox saying
"sbcl.exe stopped working..."

and then shows some more details. Tried to translate the names from danish so they might be a bit inaccurate.

Problem signature:
  name of problem event: APPCRASH
  program name: sbcl.exe
  Programversion: 0.0.0.0
  Timestamp for program: 524e570c
  Error module name: StackHash_2264
  Error module version: 0.0.0.0
  Timestamp for Error module: 00000000
  Exception code: c0000005
  Undtagelsesforskydning(dont know translation "exception shift"?): PCH_89
  OS-version: 6.3.9600.2.0.0.768.101
  Country standard-id: 1030
  More information 1: 2264
  More information 2: 2264db07e74365624c50317d7b856ae9
  More information 3: 875f
  More information 4: 875fa2ef9d2bdca96466e8af55d1ae6e

>What happens in the first try?
When i run through sbcl.exe i get sb-kernel::control-stack-exhausted and then "...this is possible due to heavily nested or infinetely recursive function cals, or a tail call that SBCL cannot or has not optimized away"

>Is this equivalent to what you experience?
it is not.

** cmd.exe dump (i replaced "req-sqrt" with "r" and used + 1 instead of sqrt) **
C:\Program Files (x86)\Steel Bank Common Lisp\1.1.17>sbcl.exe
This is SBCL 1.1.17, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

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.

WARNING: the Windows port is fragile, particularly for multithreaded
code. Unfortunately, the development team currently lacks the time
and resources this platform demands.
* (defun r (v) (+ 1 (r v))) (r 1)

R
*
debugger invoked on a SB-KERNEL::CONTROL-STACK-EXHAUSTED in thread
#<THREAD "main thread" RUNNING {240F3CF1}>:
  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.
0

(R 1)
0] 0

* (r 1)

C:\Program Files (x86)\Steel Bank Common Lisp\1.1.17>

** **
sbcl crashes between the last (r 1) and C:\Program FIles (x86)...

Revision history for this message
Douglas Katzman (dougk) wrote :

Not sure what's being asked. Of course if overflows the stack since it's infinitely recursive.

Changed in sbcl:
status: New → Incomplete
Revision history for this message
Luís Oliveira (luismbo) wrote :
Changed in sbcl:
assignee: nobody → Luís Oliveira (luismbo)
status: Incomplete → Fix Committed
Changed in sbcl:
status: Fix Committed → Fix Released
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.