Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.85k stars 523 forks source link

Re: SIGSEGV in Perl_gv_check: entry filled with ASCII '0000' #6455

Closed p5pRT closed 20 years ago

p5pRT commented 21 years ago

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

Searchable as RT21984$

p5pRT commented 21 years ago

From ks.perl@kurtstephens.com

Update --

A friend running Apple OS X with stock perl 5.6.0 said it does not dump core when running uml2code/test/test4.pl\, if you install XML​::Writer 0.1. Oddly\, XML​::Writer v0.2-0.4 cause OS X perl 5.6.0 to segfault in test 40. I've encouraged him to post a separate perlbug for that.

He also said that Debian woody Intel with stock perl 5.6.1 also segaults on uml2code/test/test4.pl.

Thanks\, Kurt Stephens ks.perl@​kurtstephens.com

Apple OS X perl -V

This is what perl -V outputs on Mac OS X 10.2.5​:

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration​:   Platform​:   osname=darwin\, osvers=6.0\, archname=darwin   uname='darwin fisheye 6.0 darwin kernel version 5.2​: mon jun 17 09​:55​:14 pdt 2002; root​:xnu-201-14.rootsxnu-201-14.objrelease_ppc power macintosh powerpc '   config_args='-ds -e -Dprefix=/usr -Dccflags=-g -pipe -Dldflags='   hint=recommended\, useposix=true\, d_sigaction=define   usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef   useperlio=undef d_sfio=undef uselargefiles=define   use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef   Compiler​:   cc='cc'\, optimize='-Os'\, gccversion=Apple cpp-precomp 6.14   cppflags='-g -pipe -pipe -fno-common -no-cpp-precomp -flat_namespace -DHAS_TELLDIR_PROTOTYPE -fno-strict-aliasing'   ccflags ='-g -pipe -pipe -fno-common -no-cpp-precomp -flat_namespace -DHAS_TELLDIR_PROTOTYPE -fno-strict-aliasing'   stdchar='char'\, d_stdstdio=undef\, usevfork=true   intsize=4\, longsize=4\, ptrsize=4\, doublesize=8   d_longlong=define\, longlongsize=8\, d_longdbl=define\, longdblsize=8   ivtype='long'\, ivsize=4\, nvtype='double'\, nvsize=8\, Off_t='off_t'\, lseeksize=8   alignbytes=8\, usemymalloc=n\, prototype=define   Linker and Libraries​:   ld='cc'\, ldflags =''   libpth=/usr/lib   libs=-lm -lc   libc=/System/Library/Frameworks/System.framework/System\, so=dylib\, useshrplib=true\, libperl=libperl.dylib   Dynamic Linking​:   dlsrc=dl_dyld.xs\, dlext=bundle\, d_dlsymun=undef\, ccdlflags=' '   cccdlflags=' '\, lddlflags='-bundle -flat_namespace -undefined suppress'

Characteristics of this binary (from libperl)​:   Compile-time options​: USE_LARGE_FILES   Built under darwin   Compiled at Jul 14 2002 04​:04​:33   @​INC​:   /System/Library/Perl/darwin   /System/Library/Perl   /Library/Perl/darwin   /Library/Perl   /Library/Perl   /Network/Library/Perl/darwin   /Network/Library/Perl   /Network/Library/Perl   .

=====================================================================

stephens@​localhost.localdomain wrote​:

This is a bug report for perl from stephens@​ion09.dev.ionink.com\, generated with the help of perlbug 1.34 running under perl v5.8.0.

----------------------------------------------------------------- [Please enter your report here]

I have a set of Perl modules that cause memory corruption and subsequent SIGSEGV. This bug seems to go back to at least Perl 5.6.1.

At first I was using a stock perl5.6.1 and perl5.8.0 on RedHat 8.0. They were Configured without -Dusemyalloc\, this was crashing in a libc malloc() internal function\, in both perl5.6.1 and perl5.8.0\, during parsing. I recompiled perl5.8.0 with -Dusemymalloc and -Doptimize='-g'\, to rule out problems with libc malloc().

Here is the stacktrace from gdb​:

====================================================================

Current directory is /tmp/stephens/perl-5.8.0-debug/src/perl-5.8.0/ GNU gdb Red Hat Linux (5.2.1-4) Copyright 2002 Free Software Foundation\, Inc. GDB is free software\, covered by the GNU General Public License\, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-redhat-linux"... /tmp/stephens/perl-5.8.0-debug/src/perl-5.8.0/test4.pl​: No such file or directory. (gdb) cd /home/stephens/ion/src/uml2code/test Working directory /home/stephens/ion/src/uml2code/test. (gdb) run test4.pl Starting program​: /tmp/stephens/perl-5.8.0-debug/src/perl-5.8.0/perl test4.pl

Program received signal SIGSEGV\, Segmentation fault. 0x080698ba in Perl_gv_check (stash=0x8247b80) at gv.c​:1153 (gdb) bt #0 0x080698ba in Perl_gv_check (stash=0x8247b80) at gv.c​:1153 #1 0x08069915 in Perl_gv_check (stash=0x823a850) at gv.c​:1157 #2 0x08069915 in Perl_gv_check (stash=0x816108c) at gv.c​:1157 #3 0x0805fe4d in S_parse_body (env=0x0\, xsinit=0x805caa0 \<xs_init>) at perl.c​:1548 #4 0x0805efec in perl_parse (my_perl=0x815ff08\, xsinit=0x805caa0 \<xs_init>\, argc=2\, argv=0xbfffe0e4\, env=0x0) at perl.c​:1041 #5 0x0805ca52 in main (argc=2\, argv=0xbfffe0e4\, env=0xbfffe0f0) at perlmain.c​:83 #6 0x420158d4 in __libc_start_main () from /lib/i686/libc.so.6 (gdb) up #1 0x08069915 in Perl_gv_check (stash=0x823a850) at gv.c​:1157 (gdb) up #2 0x08069915 in Perl_gv_check (stash=0x816108c) at gv.c​:1157 (gdb) p hv $1 = (struct hv *) 0x823a850 (gdb) p *hv $2 = {sv_any = 0x8236468\, sv_refcnt = 4\, sv_flags = 536870923} (gdb) p hv->sv_any $3 = (struct xpvhv *) 0x8236468 (gdb) p *(hv->sv_any) $4 = {xhv_array = 0x81d9c08 ""\, xhv_fill = 3\, xhv_max = 7\, xhv_keys = 3\, xnv_nv = 0\, xmg_magic = 0x0\, xmg_stash = 0x0\, xhv_riter = -1\, xhv_eiter = 0x0\, xhv_pmroot = 0x0\, xhv_name = 0x81fe628 "UML"} (gdb) do #1 0x08069915 in Perl_gv_check (stash=0x823a850) at gv.c​:1157 (gdb) p *(hv->sv_any) $5 = {xhv_array = 0x8166e08 "\003\003\003\003\003\0034\v (\022\v"\, xhv_fill = 13\, xhv_max = 31\, xhv_keys = 16\, xnv_nv = 0\, xmg_magic = 0x0\, xmg_stash = 0x0\, xhv_riter = -1\, xhv_eiter = 0x0\, xhv_pmroot = 0x0\, xhv_name = 0x82c5128 "UML​::MetaMetaModel"} (gdb) do #0 0x080698ba in Perl_gv_check (stash=0x8247b80) at gv.c​:1153 (gdb) p entry $6 = (struct he *) 0x3030303 (gdb) p (char)0x30 $7 = 48 '0' (gdb) l 1148
1149 if (!HvARRAY(stash)) 1150 return; 1151 for (i = 0; i \<= (I32) HvMAX(stash); i++) { 1152 for (entry = HvARRAY(stash)[i]; entry; entry = HeNEXT(entry)) { 1153 if (HeKEY(entry)[HeKLEN(entry)-1] == '​:' && 1154 (gv = (GV*)HeVAL(entry)) && (hv = GvHV(gv))) 1155 { 1156 if (hv != PL_defstash && hv != stash) 1157 gv_check(hv); /* nested package */ (gdb) p i $8 = 0 (gdb)

====================================================================

The first entry of the "stash" hash array in the "UML​::MetaMetaModel" stash appears to be corrupted\, which send "entry" into outer space to a planet filled with ASCII '0' ("zero"\, not null) characters.

The script "test4.pl" is part of a UML meta-meta-model toolkit\, "uml2code"\, I am working on. It generates a Perl (\, XMI or Java) implementation of the UML meta-model by bootstrapping from with a meta-meta-model\, which is a subset of the meta-model. Whew!

You can download uml2code at http​://kurtstephens.com/pub/uml2code/release/uml2code-20030417.tar.gz

I have not been able to get it to happen with a smaller code set. The failure maybe related to the really hairy Data​::Dumper code in uml2code/test/gen/UML/MetaModel.pm.

Prerequisites for uml2code are Parse​::RecDescent and XML​::Writer.

Something related​: If you run perl -DT test4.pl it doesn't SIGSEGV\, it fail with "Can't call method "generalization" on unblessed reference at ../lib/perl/UML/MetaMetaModel/Util.pm line 269." (after a really long time; go eat lunch). This die() is probably my fault.

Please let me know how I can help.

Thanks\, Kurt Stephens ks.perl@​kurtstephens.com

====================================================================

[Please do not change anything below this line] ----------------------------------------------------------------- --- Flags​: category=core severity=critical --- Site configuration information for perl v5.8.0​:

Configured by stephens at Thu Apr 17 01​:49​:56 EDT 2003.

Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration​: Platform​: osname=linux\, osvers=2.4.18-24.8.0\, archname=i686-linux uname='linux ion09 2.4.18-24.8.0 #1 fri jan 31 06​:51​:30 est 2003 i686 i686 i386 gnulinux ' config_args='-des -Dusemymalloc -Uinstalluserbinperl -Dprefix=/tmp/stephens/perl-5.8.0-debug -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=y\, bincompat5005=undef Compiler​: cc='cc'\, ccflags ='-DDEBUGGING -fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm'\, optimize='-g'\, cppflags='-DDEBUGGING -fno-strict-aliasing -I/usr/include/gdbm' ccversion=''\, gccversion='3.2 20020903 (Red Hat Linux 8.0 3.2-7)'\, 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='cc'\, ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lnsl -lgdbm -ldb -ldl -lm -lc -lcrypt -lutil perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil libc=/lib/libc-2.2.93.so\, so=so\, useshrplib=false\, libperl=libperl.a gnulibc_version='2.2.93' Dynamic Linking​: dlsrc=dl_dlopen.xs\, dlext=so\, d_dlsymun=undef\, ccdlflags='-rdynamic' cccdlflags='-fpic'\, lddlflags='-shared -L/usr/local/lib'

Locally applied patches​:

--- @​INC for perl v5.8.0​: /home/stephens/local/lib/site_perl/5.6.1 /home/stephens/local/lib/site_perl/5.6.1 /tmp/stephens/perl-5.8.0-debug/lib/5.8.0/i686-linux /tmp/stephens/perl-5.8.0-debug/lib/5.8.0 /tmp/stephens/perl-5.8.0-debug/lib/site_perl/5.8.0/i686-linux /tmp/stephens/perl-5.8.0-debug/lib/site_perl/5.8.0 /tmp/stephens/perl-5.8.0-debug/lib/site_perl .

--- Environment for perl v5.8.0​: HOME=/home/stephens LANG=en_US.UTF-8 LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/home/stephens/local/bin​:/home/stephens/bin​:/home/stephens/ion/src/bin​:/home/stephens/ion/src/sbin​:/home/stephens/ion/bin​:/usr/sbin​:/sbin​:/iimp/app/p/java/prod/bin​:/iimp/app/prod/bin​:/usr/kerberos/bin​:/usr/local/sbin​:/usr/local/bin​:/usr/local/bin​:/bin​:/usr/bin​:/usr/X11R6/bin PERL5LIB=/home/stephens/local/lib/site_perl/5.6.1​:/home/stephens/local/lib/site_perl/5.6.1​: PERL_BADLANG (unset) SHELL=/bin/bash