> 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?

How about also fixing the source of the problem?

--- XSUB.h.orig Wed Dec 10 20:39:37 2003
+++ XSUB.h      Wed Dec 10 20:43:26 2003
@@ -193,7 +193,8 @@

 #define XSRETURN(off)                                  \
     STMT_START {                                       \
-       PL_stack_sp = PL_stack_base + ax + ((off) - 1); \
+       IV tMpOfF = off;                                \
+       PL_stack_sp = PL_stack_base + ax + (tMpOfF - 1);\
        return;                                         \
     } STMT_END


-- Marcus

Reply via email to