On Wed, Jul 02, 2003 at 07:52:17AM +0900, Simon Strandgaard wrote:
> I were experimenting with Init_stack, when I discovered a flaw in my mind.
> 
> I thought that: local variables on stack would be marked in the
> mark-phase and therefore survive the sweep-phase.
> 
> But my instance is being destroyed.. why ?
> 
> Can someone enligthen me ?
[...] 
> int main(int argc, char **argv) {
>     ruby_init();
>     Init_dummy();
>     test();
>     return 0;
> }

Could you please check if adding one stack frame in between works?
If it does, it'd mean it's exactly the same issue described in the links
I provided some time ago, that is, that ruby_init is capturing the
current SP to record the beginning of the stack, but you're storing
VALUEs in a stack frame above.

Please test adding the following to your code:

void foo()
{ 
 int a, b, c, d, e, f; /* just to take place in the stack */
 a = b = c = d = e = f = 1; /* don't get warnings when -Wall */
 test();
}

int main(int argc, char **argv[])
{
 ruby_init();
 Init_dummy();
 foo();
 return 0;
}

Cannot check now as my primary machine has no connection and the one
I'm writing from has no ruby...

-- 
 _           _                             
| |__   __ _| |_ ___ _ __ ___   __ _ _ __  
| '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ 
| |_) | (_| | |_\__ \ | | | | | (_| | | | |
|_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_|
	Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

Those who don't understand Linux are doomed to reinvent it, poorly.
	-- unidentified source