Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault on &DB::sub declared but not defined #7866

Closed
p5pRT opened this issue Apr 8, 2005 · 4 comments
Closed

Segfault on &DB::sub declared but not defined #7866

p5pRT opened this issue Apr 8, 2005 · 4 comments

Comments

@p5pRT
Copy link

p5pRT commented Apr 8, 2005

Migrated from rt.perl.org#34892 (status was 'resolved')

Searchable as RT34892$

@p5pRT
Copy link
Author

p5pRT commented Apr 8, 2005

From ambrus@math.bme.hu

Created by ambrus@math.bme.hu

The following code segfaults my perl​:

  perl -we 'sub DB​::sub; sub foo { } BEGIN { $^P |= 1; } foo();'

I belive that pure perl should never segfault without a reason, so unless
you know a good reason for this, I consider this a bug.

Here, the BEGIN { $^P |= 1 } part should make perl call &DB​::sub on entry
to the function foo. If I define &DB​::sub, this works fine. If I don't
even declare &DB​::sub, foo() is called and the debugging bit is ignored.

I was able to reproduce this bug on various versions of perl (from 5.8.2
to 5.8.6) on i686-linux, and someone has reported that it happens on
windows too.

Here's a quick backtrace of perl 5.8.6 in case you cannot reproduce the
bug (but I'm sure you can)​:

  (gdb) r -we 'sub DB​::sub; sub foo { } BEGIN { $^P |= 1; } foo();'
  Starting program​: /home/ambrus/local/gperl/bin/perl -we 'sub DB​::sub; sub
  foo { } BEGIN { $^P |= 1;
  } foo();'

  Program received signal SIGSEGV, Segmentation fault.
  0x080d21e1 in Perl_pp_entersub () at pp_hot.c​:2948
  2948 if (AvREAL(av)) {
  (gdb) bt
  #0 0x080d21e1 in Perl_pp_entersub () at pp_hot.c​:2948
  #1 0x080b4004 in Perl_runops_debug () at dump.c​:1449
  #2 0x08062660 in S_run_body (oldscope=1) at perl.c​:1934
  #3 0x080621f7 in perl_run (my_perl=0x8174c70) at perl.c​:1853
  #4 0x0805e73a in main (argc=3, argv=0xbffff854, env=0xbffff864) at
  perlmain.c​:98
  (gdb) p av
  $1 = (AV *) 0x8172298
  (gdb) p *av
  $2 = {sv_any = 0x0, sv_refcnt = 2147483645, sv_flags = 8388608}

Now AvREAL(av) calls AvFLAGS(av) which tries to dereference SvANY(av)
which is really av->sv_any, that is, a null pointer, so it segfaults; but
I don't know why I'm saying this because surely it won't help you much.

Thanks,

ambrus

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl v5.8.6:

Configured by ambrus at Thu Mar 24 20:47:34 CET 2005.

Summary of my perl5 (revision 5 version 8 subversion 6) configuration:
  Platform:
    osname=linux, osvers=2.4.29, archname=i686-linux
    uname='linux king 2.4.29 #1 fri mar 4 22:34:34 cet 2005 i686 pentium ii (deschutes) genuineintel gnulinux '
    config_args='-Dprefix=~ambrus/local/gperl/ -Doptimize=-g'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags ='-DDEBUGGING -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-g',
    cppflags='-DDEBUGGING -fno-strict-aliasing -pipe -I/usr/local/include'
    ccversion='', gccversion='3.4.3', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/libc-2.3.2.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.3.2'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    


@INC for perl v5.8.6:
    /home/ambrus/local/gperl/lib/5.8.6/i686-linux
    /home/ambrus/local/gperl/lib/5.8.6
    /home/ambrus/local/gperl//lib/site_perl/5.8.6/i686-linux
    /home/ambrus/local/gperl//lib/site_perl/5.8.6
    /home/ambrus/local/gperl//lib/site_perl
    .


Environment for perl v5.8.6:
    HOME=/home/ambrus
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/ambrus/local/bin:/usr/local/bin:/bin:/usr/bin:/usr/games/bin:/usr/X11R6/bin:/usr/qt/3/bin:/usr/kde/3.2/bin:/opt/Acrobat5
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Apr 10, 2005

From @rgs

Zsban Ambrus wrote​:

The following code segfaults my perl​:

perl -we 'sub DB​::sub; sub foo { } BEGIN { $^P |= 1; } foo();'

I belive that pure perl should never segfault without a reason, so unless
you know a good reason for this, I consider this a bug.

Thanks for this report; I've fixed this bug in the development version
of perl with change #24215.

@p5pRT
Copy link
Author

p5pRT commented Apr 10, 2005

The RT System itself - Status changed from 'new' to 'open'

@p5pRT p5pRT closed this as completed Apr 10, 2005
@p5pRT
Copy link
Author

p5pRT commented Apr 10, 2005

@rgs - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant