Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Ruby and Mac OS X: stack level limit?

0 views
Skip to first unread message

Roy Patrick Tan

unread,
Nov 23, 2001, 10:20:17 PM11/23/01
to
Hi,

I recently downloaded Ruby fot Mac OS X (following the link from Apple's
page). I tried to install rockit, but got a "stack level too deep
error." Basically, it seems the OS X implementation for ruby only allows
up to a certain (low) call stack depth.

I wrote this simple power procedure:

---

def power(base, n)
if (n == 1) then
return base
elsif (n == 0) then
return 1
else
return base * power(base, n - 1)
end
end

1000.times do |x|
print(x, ": ", power(2,x), "\n")
end

---

Ruby on OS X will only run up to x = 35 :

35: 34359738368
test.rb:7:in `power': stack level too deep (SystemStackError)

While ruby in linux will complete the program.

The download from apple was for Ruby 1.6.4, and I tried compiling 1.6.5
but got the same problem.

Has anyone experienced a similar problem?

Roy Patrick Tan

unread,
Nov 23, 2001, 11:52:49 PM11/23/01
to
Roy Patrick Tan wrote:

> Hi,
>
> I recently downloaded Ruby for Mac OS X (following the link from Apple's

> page). I tried to install rockit, but got a "stack level too deep
> error." Basically, it seems the OS X implementation for ruby only allows
> up to a certain (low) call stack depth.

Hm, after mucking about in the code, I got around the problem by setting
the stack limit to the maximum. I don't really program at this low
level, so I'm not sure this is the correct way, but below is the diff
output for eval.c, it seems to work, at least for my system.


5990c5990,599

< double space = (double)rlim.rlim_cur*0.2;
---
>
> double space;
>
> rlim.rlim_cur = rlim.rlim_max;
> setrlimit(RLIMIT_STACK, &rlim);
>
> space = (double)rlim.rlim_cur*0.2;


Luc

unread,
Nov 24, 2001, 6:28:51 AM11/24/01
to
Roy Patrick Tan <rt...@vt.edu> wrote:

> Ruby on OS X will only run up to x = 35 :

On my OSX 10.1.1, using ruby 1.7.2 fresh from the CVS repository, I can
only go up to level 25...

--
Luc - luc...@mac.com

0 new messages