Skip to content

Regexp memory corruption with large tries #23388

Open
@pengvado

Description

@pengvado

The following script crashes with "regexp memory corruption at ./foo.pl line 4."

use re "Debug";
$x = join "|", "aaa".."mzz";
$y = join "|", "naa".."zzz";
"fnord" =~ m/(?:$x)|(?:$y)/;

The "use re 'Debug';" line is part of triggering the bug; the same regexp without debugging doesn't crash.

I have reproduced this with perl-5.38.2 and 5.40.2 and 5.42.RC1.
perl-5.36.0 is not affected.
Git bisect blames acababb.


Perl configuration
Summary of my perl5 (revision 5 version 40 subversion 2) configuration:
  Commit id: 2e0f6a60c12ff9b5fd18e5a18d350b4366ea12b7
  Platform:
    osname=linux
    osvers=6.6.21-gentoo-dist
    archname=x86_64-linux
    uname='linux pai 6.6.21-gentoo-dist #1 smp preempt_dynamic thu apr 11 23:32:55 -00 2024 x86_64 amd ryzen 9 7950x 16-core processor authenticamd gnulinux '
    config_args='-de -Dmksymlinks -Dprefix=/usr/local'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=undef
    usemultiplicity=undef
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
  Compiler:
    cc='cc'
    ccflags ='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    optimize='-O2'
    cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong'
    ccversion=''
    gccversion='13.2.1 20240113'
    gccosandvers=''
    intsize=4
    longsize=8
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=16
    longdblkind=3
    ivtype='long'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='off_t'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='cc'
    ldflags =' -fstack-protector-strong -L/usr/local/lib'
    libpth=/usr/lib /usr/local/lib /lib64 /usr/lib64 /lib /usr/local/lib64
    libs=-lpthread -lgdbm -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
    perllibs=-lpthread -ldl -lm -lcrypt -lutil -lc
    libc=/lib/../lib64/libc.so.6
    so=so
    useshrplib=false
    libperl=libperl.a
    gnulibc_version='2.38'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=so
    d_dlsymun=undef
    ccdlflags='-Wl,-E'
    cccdlflags='-fPIC'
    lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector-strong'


---
@INC for perl 5.40.2:
    /usr/local/lib/perl5/site_perl/5.40.2/x86_64-linux
    /usr/local/lib/perl5/site_perl/5.40.2
    /usr/local/lib/perl5/5.40.2/x86_64-linux
    /usr/local/lib/perl5/5.40.2
    /usr/local/lib/perl5/site_perl

---
Environment for perl 5.40.2:
    HOME=/home/pengvado
    LANG=en_US.utf8
    LANGUAGE (unset)
    LC_COLLATE=C
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/local/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin
    PERL_BADLANG (unset)
    SHELL=/bin/zsh

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions