develooper Front page | perl.perl5.porters | Postings from November 2011

[perl #99850] Segmentation fault when a destructor kills a sub about to be goto'd into

Thread Previous | Thread Next
From:
Father Chrysostomos via RT
Date:
November 27, 2011 12:30
Subject:
[perl #99850] Segmentation fault when a destructor kills a sub about to be goto'd into
Message ID:
rt-3.6.HEAD-5084-1322425809-390.99850-15-0@perl.org
On Sat Nov 26 22:27:35 2011, sprout wrote:
> On Thu Sep 29 13:29:31 2011, nicholas wrote:
> > On Thu, Sep 29, 2011 at 09:55:53PM +0200, Vincent Pit wrote:
> > > 
> > > > I'm not even sure what the right behaviour should be. [and once
there 
> > > > are some candidates for that, how to implement them] Nicholas Clark 
> > > 
> > > Thanks for searching the history.
> > > 
> > > I believe the right behaviour is goto'ing into whatever is alive
before 
> > > destructors are processed. That's how it used to work on 5.6
(maybe at 
> > > the price of numerous oddities and bugs, I don't know enough to say), 
> > > and is in line with what happens when the code is freed at goto()
time :
> > > 
> > >      sub swish {
> > >       say 'original'
> > >      }
> > > 
> > >      sub rakkk {
> > >       local *swish = sub { say 'local' };
> > >       goto &swish;
> > >      }
> > > 
> > >      rakkk() # says "local"
> > > 
> > > To implement this, I suspect it is enough to save
CvROOT()/CvXSUB() at 
> > > the beginning of pp_goto(), then proceed to LEAVE_SCOPE(), and then
> call 
> > > the saved value. After all, pp_goto() is already temporarily bumping
> the 
> > > refcount of the CV to make the local example work, and that
strategy is 
> > > quite similar.
> > 
> > That approach is not going to restore the pre 5.8 behaviour for the
> example
> > with a DESTROY that explicity uses undef on the subroutien. You'd get a
> > "Can't undef active subroutine" error.
> 
> The most logical fix, IMO, is to check to make sure that CvXSUB or
> CvROOT is still present and die with ‘Undefined subroutine called’
instead.
> 

I fixed it this way, but with the correct error message, with commit
1d59c03.


-- 

Father Chrysostomos


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About