[#1611] set_trace_func/Array#fetch error — "Nathaniel Talbott" <nathaniel@...>

I've reduced the error I reported in ruby-talk:84013 to the following code:

17 messages 2003/10/11

Re: SystemStackError in embedding

From: Mathieu Bouchard <matju@...>
Date: 2003-10-19 22:08:58 UTC
List: ruby-core #1646
On Sun, 19 Oct 2003, Sentinel wrote:

> I am calling ruby_init from within the constructor of the XMRuby class
> I put the 'fprintf' line both before the ruby_init and in the same
> function where the rb_protect, that generates the error, is called:
> Output at ruby_init:
> ruby_init. Stack pointer==bfffe5fc
> Output at Error:
> Error. Stack pointer==bfffecfc
> Error in calling timer (6)
> class = SystemStackError
> message = stack level too deep
> backtrace =     from /usr/lib/ruby/1.8/delegate.rb:36

Assuming you're on i686-compatible chips, then this is a known bug that
still has not been fixed, afaik, but I wouldn't know, as I applied the fix
from inside my own program.

See [ruby-core:01278] (july 2003) in the archives for code on how to find
the real stack-pointer. That was the conclusion to a very frustrating bug
I had been sweating about for a whole year.

You would then pass the value of that to the following undocumented
function of libruby.so :

extern "C" void Init_stack(VALUE *addr);

Matz thinks my solution is not nice: to be exact, when I proposed the
above solution, he said that he didn't know how *he* would do it.

To avoid the semblance of big hack involving a voluntary segfault and
similar blackmagic, you could hardcode the value 0xBFFFFFFC in your
program, but be warned that this only works on i686-linux and compatible,
and may fail on just about every other platform.

________________________________________________________________
Mathieu Bouchard                       http://artengine.ca/matju


In This Thread