Can't pass millions of arguments to a function.

Bug #1833881 reported by Jeremy Phelps
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Invalid
Undecided
Unassigned

Bug Description

I attempted to add a list of a million integers like this:

    (apply #'+ (loop repeat 1000000 collect (random 1000))

It does not come as a total surprise that this resulted in the message
"Control stack guard page temporarily disabled: proceed with caution", and
trying it again got me acquainted with the ldb> prompt.

But I'm reporting this as a bug anyway. What happened is reasonable, but not ideal behavior. The above operation should just work, no matter how long the list-of-integers is.

Revision history for this message
Stas Boukarev (stassats) wrote :

> The above operation should just work

But it can't work. The stack is a limited resource.

Changed in sbcl:
status: New → Invalid
Revision history for this message
Jeremy Phelps (username00001) wrote :

It _can_ work. Just don't put &rest arguments on the stack.
In the end, you have to allocate cons cells for them anyway
so that the function sees a list.

Try this in Racket:

   (require (planet jphelps/loop))
   (apply + (loop repeat 1000000 collect (random 1000))

Revision history for this message
Stas Boukarev (stassats) wrote :

> Just don't put &rest arguments on the stack.

I love the way you say "just". "Just make all programs slow!". Let's start from the fact that the caller doesn't know that the callee is using &rest.

> In the end, you have to allocate cons cells for them anyway so that the function sees a list.

That's not true. No lists are allocated by the + function.

And after this, will it be "I can't call a recursive function a million times, please, allocate frames on the heap."?

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.