What’s your OS? BTW, it is a known issue with Mac OS X where in most
cases you must increase the default stack size.
How?
In bash, “ulimit -s” shows the current stack size in kbytes (defaults
to 8192 in Mac OS X, really low). To change it issue “ulimit -s
”.
The command may be different for other shells. You may put this command
in /etc/profile to be set every time a user logs in.
Gennady.
It happens both with
Ruby 1.6.8 on BSD Unix
Ruby 1.8.0 on Win2000
The above command will work for BSD Unix too. I do not know how to do
it for Win2000.
Are you sure that there’s no actual problem with your program? It may
really be run-away in recursion, so increasing the stack size will only
make the problem happen somewhat later.
What’s your OS? BTW, it is a known issue with Mac OS X where in most
cases you must increase the default stack size.
How?
In bash, “ulimit -s” shows the current stack size in kbytes (defaults
to 8192 in Mac OS X, really low). To change it issue “ulimit -s
”.
The command may be different for other shells. You may put this command
in /etc/profile to be set every time a user logs in.
Gennady.
It happens both with
Ruby 1.6.8 on BSD Unix
Ruby 1.8.0 on Win2000
The above command will work for BSD Unix too. I do not know how to do
it for Win2000.
Are you sure that there’s no actual problem with your program? It may
really be run-away in recursion, so increasing the stack size will only
make the problem happen somewhat later.
13281
13282
13283
-e:1:in `p': stack level too deep (SystemStackError)
from -e:1:in `t'
from -e:1:in `t'
from -e:1:in `t'
from -e:1:in `t'
from -e:1:in `t'
from -e:1:in `t'
from -e:1:in `t'
from -e:1:in `t'
... 13274 levels...
from -e:1:in `t'
from -e:1:in `t'
from -e:1:in `t'
from -e:1
2047
This means that a stack size of approx 2MB suffices only for 13000+ stack
levels. IOW about 157 bytes per stack frame.
on a sidenote, someone I know has the same max stack size as me
(8192), and with slightly different versions of 1.8.1, on debian he’s
got a SystemStackError calculating ackermann(3,7), while I can even
calculate ackermann(3,8).
I’m not a unix guru, may be possible that there are other things to
look for?
the ackermann implementation is:
def ackermann(m, n)
if m == 0
n + 1
elsif n == 0
ack(m - 1, 1)
else
ack(m - 1, ack(m, n - 1))
end
end
···
il Thu, 15 Jan 2004 17:18:17 +0900, Gennady gfb@tonesoft.com ha scritto::
On Jan 14, 2004, at 23:31, Jesper Olsen wrote:
In bash, “ulimit -s” shows the current stack size in kbytes (defaults
to 8192 in Mac OS X, really low). To change it issue “ulimit -s
”.
il Thu, 15 Jan 2004 17:18:17 +0900, Gennady gfb@tonesoft.com ha
scritto::
I had the same problem with stacksize too low on a MAC OS X,
running the 3n+1 problem. It would go till the number in the 30s
where there are many iterations, then give me the stacksize
error. Increasing the stacksize solved the problem.