Skip to content

Setting breakpoint on AUTOLOAD causes segmentation fault #19198

Closed
@FractalBoy

Description

@FractalBoy

Description
Setting a breakpoint on an AUTOLOAD under certain circumstances causes a segmentation fault. It's unclear what is the minimum amount of code required to reproduce the issue, but at the very least it seems to require:

  1. Two or more stack frames
  2. An eval block
  3. use vars for $AUTOLOAD
  4. Assigning $AUTOLOAD to another variable

I was able to reproduce this on both 5.32 and 5.34.

Steps to Reproduce

I was able to get this code to segfault, but it didn't happen every time.

package Test;

sub AUTOLOAD {
    use vars '$AUTOLOAD';
    my $sub = $AUTOLOAD;
    return 1;
}

package main;


sub test
{
    Test::test();
}

sub test_test
{
    eval { test() };
}

test_test();

Start the perl debugger with this code, then set a breakpoint on Test::AUTOLOAD, and continue. You should get this error message:

Signal SEGV at autoload_segv.pl line 14.
        main::test() called at autoload_segv.pl line 19
        eval {...} called at autoload_segv.pl line 19
        main::test_test() called at autoload_segv.pl line 22
Aborted (core dumped)

Expected behavior
It should break on the first line of the AUTOLOAD subroutine and not segfault.

Perl configuration

Summary of my perl5 (revision 5 version 34 subversion 0) configuration:
   
  Platform:
    osname=linux
    osvers=4.18.0-305.el8.x86_64
    archname=x86_64-linux
    uname='linux vm-mreisner.epic.com 4.18.0-305.el8.x86_64 #1 smp thu may 27 16:46:28 utc 2021 x86_64 x86_64 x86_64 gnulinux '
    config_args='-de -Dprefix=/home/mreisner/perl5/perlbrew/perls/perl-5.34.0 -Aeval:scriptdir=/home/mreisner/perl5/perlbrew/perls/perl-5.34.0/bin'
    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 -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2'
    optimize='-O2'
    cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    ccversion=''
    gccversion='8.4.1 20200928 (Red Hat 8.4.1-1)'
    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/local/lib /usr/lib /usr/lib64 /usr/local/lib64
    libs=-lpthread -ldl -lm -lcrypt -lutil -lc
    perllibs=-lpthread -ldl -lm -lcrypt -lutil -lc
    libc=libc-2.28.so
    so=so
    useshrplib=false
    libperl=libperl.a
    gnulibc_version='2.28'
  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'


Characteristics of this binary (from libperl): 
  Compile-time options:
    HAS_TIMES
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    USE_64_BIT_ALL
    USE_64_BIT_INT
    USE_LARGE_FILES
    USE_LOCALE
    USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
    USE_LOCALE_TIME
    USE_PERLIO
    USE_PERL_ATOF
  Built under linux
  Compiled at Jun 24 2021 16:29:28
  %ENV:
    PERLBREW_HOME="/home/mreisner/.perlbrew"
    PERLBREW_MANPATH="/home/mreisner/perl5/perlbrew/perls/perl-5.34.0/man"
    PERLBREW_PATH="/home/mreisner/perl5/perlbrew/bin:/home/mreisner/perl5/perlbrew/perls/perl-5.34.0/bin"
    PERLBREW_PERL="perl-5.34.0"
    PERLBREW_ROOT="/home/mreisner/perl5/perlbrew"
    PERLBREW_SHELLRC_VERSION="0.92"
    PERLBREW_VERSION="0.92"
  @INC:
    /home/mreisner/perl5/perlbrew/perls/perl-5.34.0/lib/site_perl/5.34.0/x86_64-linux
    /home/mreisner/perl5/perlbrew/perls/perl-5.34.0/lib/site_perl/5.34.0
    /home/mreisner/perl5/perlbrew/perls/perl-5.34.0/lib/5.34.0/x86_64-linux
    /home/mreisner/perl5/perlbrew/perls/perl-5.34.0/lib/5.34.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions