develooper Front page | perl.perl5.porters | Postings from August 2013

Re: When is PL_curcop NULL?

Thread Previous | Thread Next
Father Chrysostomos
August 6, 2013 13:12
Re: When is PL_curcop NULL?
Message ID:
Nicholas Clark wrote:
> On Mon, Aug 05, 2013 at 09:07:53AM -0000, Father Chrysostomos wrote:
> > Do we still need these [null] checks?
> I think so, but I can't prove it. Moreover, I think that S_cop_free() should
> have this:
> +    if (PL_curcop == cop)
> +       PL_curcop = NULL;
>  }
> because without that, we have an interpreter-global variable pointing to
> freed memory. And that sort of dangling pointer has been the cause of
> several different previous bugs.

I tried adding that block locally and *also* adding assert(PL_curcop)
to newGP, and got no failures.  I think that both are a good idea.  We
have many months before the next stable release and plenty of time to
smoke out places where that assertion is wrong.  (And we will leave
the null checks in newGP for now anyway, so non-debugging builds are
not sabotaged.)

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About