Nick Ing-Simmons <[EMAIL PROTECTED]> writes:

> To let Tk list know a major gotcha blocking Tk release is fixed.
> Thanks to Steve Lide for the guest account on his G5 machine
> to track this!
> 
> To let perl-xs list know even I am human and do dumb things ...
> 
> void
> WidgetMethod(widget,name,...)
> SV *  widget;
> SV *  name;
> CODE:
>  {
>   Lang_CmdInfo *info = WindowCommand(widget, NULL, 1);
>   XSRETURN(Call_Tk(info, items, &ST(0)));
>  }
> 
> Looks neat and tidy - but is fatally flawed.
> XSRETURN macro is basically 
> 
>   THE_PERL_STACK_POINTER += Something.
> 
> On Steve's G5 - that gets compiled as 
>   Get PERL_STACK_POINTER
>    call function which returns value
>    add 
>   Set PERL_STACK_POINTER
> 
> The snag is that when function which returns value is a
> perl callback it can move the stack.
> So after above the stack pointer is pointing into an old stack
> which has now been free'd and re-used => CORE. 
> 
> Changing it to:
> 
> void
> WidgetMethod(widget,name,...)
> SV *  widget;
> SV *  name;
> CODE:
>  {
>   Lang_CmdInfo *info = WindowCommand(widget, NULL, 1);
>   IV count = Call_Tk(info, items, &ST(0));
>   XSRETURN(count);
>  }
> 
> Fixes the problem.

Is this worth a note in perlapi.pod?

Regards,
        Slaven

-- 
Slaven Rezic - [EMAIL PROTECTED]

    Berlin Perl Mongers - http://berlin.pm.org

Reply via email to