| Store | Cart

Re: [perl #123007] interp struct difference, PERL_EXT_RE_DEBUG breaks ABI between re:: and core

From: Dave Mitchell <dav...@iabyn.com>
Mon, 20 Oct 2014 12:46:11 +0100
On Sat, Oct 18, 2014 at 05:35:10PM -0700, bulk88 wrote:
> I am running 5.21.5 blead perl. In testing a new perl API version check > to stop mismatches between XS libraries and interp core, I found that > the XS module re:: has a different size and definition of "struct > interpreter".
[snip]
> intrpvar.h says> > ------------------------> #ifdef PERL_TRACK_MEMPOOL> /* For use with the memory debugging code in util.c  */> PERLVAR(I, memory_debug_header, struct perl_memory_debug_header)> #endif> ------------------------> > re.xs at the top starts with> > ------------------------> #if defined(PERL_EXT_RE_DEBUG) && !defined(DEBUGGING)> #  define DEBUGGING> #endif> ------------------------> > and re::'s Makefile.PL says "my $defines = '-DPERL_EXT_RE_BUILD > -DPERL_EXT_RE_DEBUG -DPERL_EXT';" . I dont understand why this code is > here and why DEBUGGING is on, but this is unacceptable in the current state.

Adding DEBUGGING is the raison d'etre of the re module; it allows you
to execute variants of the regex engine's normal API functions with
debugging enabled, even on non-debugging builds; so on a non-debugging
perl you can do:

    perl -Mre=Debug,EXECUTE -e'"abc" =~ /a+/'

Because of this, its always been the case that the interpreter struct must
be the same on debugging and non-debugging builds; see for example this
comment in intrpvar.h:

    /* name of the scopes we've ENTERed. Only used with -DDEBUGGING, but needs to be
       present always, as -DDEBUGGING must be binary compatible with non.  */
    PERLVARI(I, scopestack_name, const char * *, NULL)

Probably the best way to fix is this to add to the two #if's above, i.e.

    - #ifdef PERL_TRACK_MEMPOOL
    + #if defined(PERL_TRACK_MEMPOOL) || defined(DEBUGGING)

    - #if defined(PERL_EXT_RE_DEBUG) && !defined(DEBUGGING)
    + #if (defined(PERL_EXT_RE_DEBUG) || defined(PERL_TRACK_MEMPOOL)) && !defined(DEBUGGING)

Then add a test to stop this happening again. Probably add a function to
both re.xs and apitest.xs that returns sizeof(struct PerlInterpreter),
then check that they match.

-- 
Dave's first rule of Opera:
If something needs saying, say it: don't warble it.

Recent Messages in this Thread
bulk88 (via RT) Oct 19, 2014 12:35 am
Dave Mitchell Oct 20, 2014 11:46 am
Messages in this thread