COPY-TREE fails with stack overflow on long lists

Bug #998926 reported by Robert Dodier on 2012-05-13
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

COPY-TREE fails with a stack overflow when its argument is a long list. (I didn't try to find out what is the minimum length to trigger the error.)

COPY-LIST succeeds on a list of the same length.

Thank you for your attention to this. I searched the bug database but didn't find a similar report. I don't see anything about COPY-TREE in the change logs.

------------------------- bug --------------------------
* (defvar x nil)

* (dotimes (i 65536) (push 1 x))

* (copy-tree x)
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
                                                                     "initial thread" RUNNING
  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.


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

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


------------------------- info --------------------------
$ sbcl --version
SBCL 1.0.49

* *features*


$ uname -a
Linux robert-laptop 2.6.24-16-generic #1 SMP Thu Apr 10 13:23:42 UTC 2008 i686 GNU/Linux

Stas Boukarev (stassats) wrote :

commit 4b25bb8e20bf3c1419a11b7d4cfefa23e4f3279b
Author: Stas Boukarev <email address hidden>
Date: Mon May 14 05:12:45 2012 +0400

    Optimize copy-tree.

    copy-tree used to always call itself, even on linear lists, which
    caused stack exhaustion on long lists. Make it copy linear lists
    linearly, and recur only when necessary. This also makes it somewhat

Changed in sbcl:
status: New → Fix Committed
Nikodemus Siivola (nikodemus) wrote :

in SBCL 1.0.57

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