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

"XXX should fix CXINC macro"

Thread Next
From:
Nicholas Clark
Date:
November 27, 2008 02:35
Subject:
"XXX should fix CXINC macro"
Message ID:
20081127103536.GA49335@plum.flirble.org
I found an XXX in the perl5 source code:

I32
Perl_cxinc(pTHX)
{
    dVAR;
    const IV old_max = cxstack_max;
    cxstack_max = GROW(cxstack_max);
    Renew(cxstack, cxstack_max + 1, PERL_CONTEXT);	/* XXX should fix CXINC macro */
    /* Without any kind of initialising deep enough recursion
     * will end up reading uninitialised PERL_CONTEXTs. */
    PoisonNew(cxstack + old_max + 1, cxstack_max - old_max, PERL_CONTEXT);
    return cxstack_ix + 1;
}


I wondered what the bug was, and why we can't fix it.

With a bit of digging it turns out that it's a patch from Larry, applied by
Andy, in early 1996:

http://perl5.git.perl.org/?p=perl.git;a=commitdiff;h=a38d6535f8637d53561bc3663eb96f6c054d0bbb;hp=c0c09dfd3cf50dacd0bf01dff34b4904c5ed1cc6

The interesting parts are:

index 360f9a0..738c95c 100644 (file)

--- a/perl.c
+++ b/perl.c

@@ -1722,7 +1745,7 @@ init_stacks()
     retstack_ix = 0;
     retstack_max = 16;
 
-    New(50,cxstack,128,CONTEXT);
+    New(50,cxstack,129,CONTEXT);       /* XXX should fix CXINC macro */
     cxstack_ix = -1;
     cxstack_max        = 128;
 

diff --git a/scope.c b/scope.c

Index 79740dc..3f48609 100644 (file)

--- a/scope.c
+++ b/scope.c
@@ -30,7 +30,7 @@ I32
 cxinc()
 {
     cxstack_max = cxstack_max * 3 / 2;
-    Renew(cxstack, cxstack_max, CONTEXT);
+    Renew(cxstack, cxstack_max + 1, CONTEXT);  /* XXX should fix CXINC macro */
     return cxstack_ix + 1;
 }



What was the problem with CXINC, and what's the correct fix?

Nicholas Clark

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