Stack level too deep on ia64

I’m working on an ia64 box to develop a MySQL/Ruby app, and I’m
getting not very helpful SystemStackError traces:

/usr/lib/ruby/1.8/thread.rb:325: stack level too deep (SystemStackError)
from /usr/lib/ruby/1.8/DBD/Mysql/Mysql.rb:34:in require' from /usr/lib/ruby/1.8/DBD/Mysql/Mysql.rb:34 from /usr/lib/ruby/1.8/dbi/dbi.rb:465:inrequire’
from /usr/lib/ruby/1.8/dbi/dbi.rb:465:in load_driver' from /usr/lib/ruby/1.8/dbi/dbi.rb:459:ineach’
from /usr/lib/ruby/1.8/dbi/dbi.rb:459:in load_driver' from /usr/lib/ruby/1.8/dbi/dbi.rb:393:in_get_full_driver’
from /usr/lib/ruby/1.8/dbi/dbi.rb:373:in connect' ... 19 levels... from /usr/lib/lts/cgi-bin/newplan:169:indisplayNewPlan’
from /usr/lib/lts/cgi-bin/newplan:168:in out' from /usr/lib/lts/cgi-bin/newplan:168:indisplayNewPlan’
from /usr/lib/lts/cgi-bin/newplan:275

so far, my efforts to reproduce this in a simple testcase have failed,
possibly due to my ignorance of what those missing 19 levels are. How
can I force ruby to display them?

-=Eric

···


Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
– Blair Houghton.

Eric Schwartz emschwar@pobox.com writes:

I’m working on an ia64 box to develop a MySQL/Ruby app, and I’m
getting not very helpful SystemStackError traces:

Okay, to follow up on my own post, I did this in irb:

irb(main):001:0> begin
irb(main):002:1* raise SystemStackError
irb(main):003:1> rescue SystemStackError => sse
irb(main):004:1> $sse = sse
irb(main):005:1> end

and played with $sse and found it has a backtrace() method. So on a
wild guess, I tried:

begin
code_that_raises_sse()
rescue SystemStackError => sse
puts “Caught SystemStackError. Backtrace:”
sse.backtrace.each { |line|
puts line.to_s
}
puts “end of backtrace”
end

Unfortunately, all that shows is that the missing 19 lines are a
perfectly ordinary backtrace that has a bunch of nested calls to a CGI
object for output. This exact same code works fine on i386, leading
me to believe this might be somehow related to the thread in:

http://lists.debian.org/debian-powerpc/2003/debian-powerpc-200310/msg00057.html

Specifically, this looks suspicious:

“It’s fine as long as the limit on the stacksize is <= 4194303 KiB,
but dies instantly if the stack size is 4194304 KiB or higher. This
is the point where more than 32 bits are needed to store an address.”

(in Re: Help to reproduce the bug (Was: Re: State of Ruby))

I’ve tried setting the ulimit at 4194303 as suggested, but it still
fails. Suggestions of how to approach this are welcome.

$ ruby -v
ruby 1.8.0 (2003-10-05) [ia64-linux]

-=Eric

···


Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
– Blair Houghton.

I’ve tried setting the ulimit at 4194303 as suggested, but it still
fails. Suggestions of how to approach this are welcome.

What is the value of STACK_LEVEL_MAX ?

See the macro CHECK_STACK in gc.c

···

Guy Decoux

ts decoux@moulon.inra.fr writes:

I’ve tried setting the ulimit at 4194303 as suggested, but it still
fails. Suggestions of how to approach this are welcome.

What is the value of STACK_LEVEL_MAX ?

49152 (see below)

See the macro CHECK_STACK in gc.c

I suspect the interesting bit is actually in Init_stack(), where there
is this section:

#ifdef ia64
/* ruby crashes on IA64 if compiled with optimizer on /
/
when if STACK_LEVEL_MAX is greater than this magic number /
/
I know this is a kludge. I suspect optimizer bug */
#define IA64_MAGIC_STACK_LIMIT 49152
if (STACK_LEVEL_MAX > IA64_MAGIC_STACK_LIMIT)
STACK_LEVEL_MAX = IA64_MAGIC_STACK_LIMIT;
#endif

-=Eric

···


Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
– Blair Houghton.