Bugs item #11134, was opened at 2007-05-25 12:14
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=1698&aid=11134&group_id=426

Category: Core
Group: 1.8.6
Status: Open
Resolution: None
Priority: 3
Submitted By: Gonzalo Garramuno (gga)
Assigned to: Nobody (None)
Summary: Init_stack and ruby_init_stack fail to reinit stack (threads problem?)

Initial Comment:
On an AMD64 box at least (albeit probably others), Init_stack and ruby_init_stack can fail to reinitialize the stack correctly.  This problem can happen when Init_stack is invoked from two different places, such as two different C threads (or two different DSOs).  At least, that's as far as I was able to reproduce the problem.
This problem is also present in the 1.9 branch.

The problem is that in those cases the STACK_UPPER() in those functions can fail incorrectly.  This can later lead to ruby incorrectly thinking it has run of stack space or to mark incorrectly some VALUEs.

There's the need for an init stack function that works reliably across threads, or, alternatively, for one that does not do the STACK_UPPER() check.


Here's a trace (with some printfs added to Init_stack and ruby_init_stack to show the problems).  This is Maya running its renderer which invokes ruby as a shading language.


ruby_init_stack: (nil) at START
ruby_init_stack: should reset to 0x7fffb12eb980
ruby_init_stack: 0x7fffb12eb980 at END
Init_stack: 0x7fffb12eb980 at START
Init_stack should reset to: 0x7fffb12eb964
Init_stack: 0x7fffb12eb980 at END   -- ** NOT RESET, but correct **
mark stack 0x7fffb12eb980 - 0x7fffb12e7820- MARKED

Starting Rendering /home/gga/maya/projects/default/images/untitled.iff.
Rendering current frame.  ** this inits a new thread **

ruby_init_stack: 0x7fffb12eb980 at START
ruby_init_stack: should reset to 0x418021d0
ruby_init_stack: 0x7fffb12eb980 at END   -- **NOT RESET, NOT CORRECT **



----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=1698&aid=11134&group_id=426