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

Re: Padlist NULL pointer?

Thread Previous | Thread Next
From:
Darin McBride
Date:
October 30, 2013 23:18
Subject:
Re: Padlist NULL pointer?
Message ID:
1552778.L8AfuXI80o@naboo
On Wednesday October 30 2013 6:26:10 PM Father Chrysostomos wrote:
> Marc Lehmann wrote:
> > With your patch, it looks as it would avoid the segfault, but it would
> > either leak memory (because it sets max to something lower), or share
> > padlists (because it doesn't steal the actual pad). Maybe I am wrong,
> > but I think removing a pad from the middle of the padlist is asking for
> > trouble.
> 
> Yes, even my supposed correction is faulty. :-(
> 
> Another try:
> 
> diff -rup Coro-6.31-eL_b57-orig/Coro/State.xs Coro-6.31-eL_b57/Coro/State.xs
> --- Coro-6.31-eL_b57-orig/Coro/State.xs2013-10-30 05:56:32.000000000 -0700
> +++ Coro-6.31-eL_b57/Coro/State.xs2013-10-30 11:24:44.000000000 -0700 @@
> -515,6 +515,9 @@ coro_derive_padlist (pTHX_ CV *cv)
>    PAD *newpad;
>    PADOFFSET const off = PadlistMAX (padlist) + 1;
> 
> +  while (!PadlistARRAY (padlist)[off-1])
> +    off--;
> +
>    newPADLIST(newpadlist);
>  #if !PERL_VERSION_ATLEAST(5,15,3)
>    /* Padlists are AvREAL as of 5.15.3. See perl bug #98092 and perl commit
> 7d953ba. */

ITYM:

--- Coro/State.xs 2013-10-30 05:56:32.000000000 -0700
+++ Coro/State.xs 2013-10-30 05:56:43.000000000 -0700
@@ -515,6 +515,9 @@ coro_derive_padlist (pTHX_ CV *cv)
   PADLIST *padlist = CvPADLIST (cv);
   PADLIST *newpadlist;
   PAD *newpad;
-  PADOFFSET const off = PadlistMAX (padlist) + 1;
+  PADOFFSET off = PadlistMAX (padlist) + 1;
+
+  while (!PadlistARRAY (padlist)[off-1])
+    off--;
 
   newPADLIST(newpadlist);
 #if !PERL_VERSION_ATLEAST(5,15,3)


(You can't modify off when it's const) :D

And this patch also continues to resolve my segfault - though I'll leave it to 
more informed people to review the patch itself and understand any other 
implications.

I'm hoping that both a short-term solution can be agreed on so I can more or 
less proceed with my development effort here, as well as the long-term 
solution so that if/when I can get up to Perl 5.20 I have less fun with it :)

Thanks,
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