Front page | perl.perl5.porters |
Postings from October 2003
[5.8.x segfault + patch] chicken&egg segfault in -Dm -Mthreads
Thread Next
From:
Stas Bekman
Date:
October 29, 2003 15:16
Subject:
[5.8.x segfault + patch] chicken&egg segfault in -Dm -Mthreads
Message ID:
3FA04A03.5010603@stason.org
perl-5.8.2-ithread -Dm -Mthreads -le 'threads->new(sub {})->detach'
segfaults:
#0 0x4013abef in Perl_PerlIO_write (my_perl=0x80ec960, f=0xabababb7,
vbuf=0x80aa4e0, count=42) at perlio.c:1576
1576 Perl_PerlIO_or_fail(f, Write, -1, (aTHX_ f, vbuf, count));
(gdb) where
#0 0x4013abef in Perl_PerlIO_write (my_perl=0x80ec960, f=0xabababb7,
vbuf=0x80aa4e0, count=42) at perlio.c:1576
#1 0x4013ff17 in PerlIO_vprintf (f=0xabababb7,
fmt=0x4015bd20 "0x%lx: (%05ld) malloc %ld bytes\n",
ap=0xbffff024 "à\0037@¸\001") at perlio.c:4829
#2 0x4013ff60 in PerlIO_printf (f=0xabababb7,
fmt=0x4015bd20 "0x%lx: (%05ld) malloc %ld bytes\n") at perlio.c:4841
#3 0x400954b4 in Perl_safesysmalloc (size=456) at util.c:72
#4 0x400a4a65 in Perl_reentrant_init (my_perl=0x80ec960) at reentr.c:143
#5 0x400d302f in perl_clone (proto_perl=0x804b2b8, flags=2) at sv.c:10619
#6 0x403a34e2 in Perl_ithread_create (my_perl=0x804b2b8, obj=0x0,
classname=0x8061fa8 "threads", init_function=0x804bf50, params=0x804c088)
at threads.xs:408
#7 0x403a3cb1 in XS_threads_new (my_perl=0x804b2b8, cv=0x806af64)
at threads.xs:644
#8 0x400b9dc1 in Perl_pp_entersub (my_perl=0x804b2b8) at pp_hot.c:2826
#9 0x40094d8a in Perl_runops_debug (my_perl=0x804b2b8) at dump.c:1438
#10 0x4003a966 in S_run_body (my_perl=0x804b2b8, oldscope=1) at perl.c:1860
#11 0x4003a3a8 in perl_run (my_perl=0x804b2b8) at perl.c:1779
#12 0x0804947e in main (argc=4, argv=0xbffff5b4, env=0xbffff5c8)
at perlmain.c:86
#13 0x40258c57 in __libc_start_main () from /lib/i686/libc.so.6
Perl_reentrant_init(aTHX) is called before IO is setup some 20
statements later:
#ifdef PERLIO_LAYERS
/* Clone PerlIO tables as soon as we can handle general xx_dup() */
PerlIO_clone(aTHX_ proto_perl, param);
#endif
so we segfault.
The problem? We get hit by the evil PERL_SET_CONTEXT again :(
This segfault is reproducable with any 5.8/5.9 build with perlio.
Here is a possible patch, though it fixes the segfault only for -Dm. I haven't
tested what happens with other -D flags. Where should the new test be added?
--- sv.c.orig 2003-10-29 15:14:21.000000000 -0800
+++ sv.c 2003-10-29 15:01:28.000000000 -0800
@@ -10616,6 +10616,7 @@
PL_debug = proto_perl->Idebug;
#ifdef USE_REENTRANT_API
+ PERL_SET_CONTEXT(proto_perl);
Perl_reentrant_init(aTHX);
#endif
may be a comment is needed just before the added line to explain why we do that?
Summary of my perl5 (revision 5.0 version 8 subversion 2) configuration:
Platform:
osname=linux, osvers=2.4.22-10mdk, archname=i686-linux
uname='linux rabbit.stason.org 2.4.22-10mdk #1 thu sep 18 12:30:58 cest
2003 i686 unknown unknown gnulinux '
config_args='-des -Dprefix=/home/stas/perl/5.8.2 -Doptimize=-g
-Duseshrplib -Dusedevel'
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='cc', ccflags ='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
optimize='-g',
cppflags='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include
-I/usr/include/gdbm'
ccversion='', gccversion='3.3.1 (Mandrake Linux 9.2 3.3.1-2mdk)',
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 -lcrypt -lutil -lc
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
libc=/lib/libc-2.3.2.so, so=so, useshrplib=true, libperl=libperl.so
gnulibc_version='2.3.2'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic
-Wl,-rpath,/home/stas/perl/5.8.2/lib/5.8.2/i686-linux/CORE'
cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'
Locally applied patches:
MAINT21558
---
@INC for perl v5.8.2:
/home/stas/perl/5.8.2/lib/5.8.2/i686-linux
/home/stas/perl/5.8.2/lib/5.8.2
/home/stas/perl/5.8.2/lib/site_perl/5.8.2/i686-linux
/home/stas/perl/5.8.2/lib/site_perl/5.8.2
/home/stas/perl/5.8.2/lib/site_perl
.
---
Environment for perl v5.8.2:
HOME=/home/stas
LANG=en_CA
LANGUAGE=en_CA:en_US:en
LC_ADDRESS=en_CA
LC_COLLATE=en_CA
LC_CTYPE=en_CA
LC_IDENTIFICATION=en_CA
LC_MEASUREMENT=en_CA
LC_MESSAGES=en_CA
LC_MONETARY=en_CA
LC_NAME=en_CA
LC_NUMERIC=en_CA
LC_PAPER=en_CA
LC_TELEPHONE=en_CA
LC_TIME=en_CA
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/usr//bin:/bin:/usr/bin:.:/usr/local/bin:/usr/X11R6/bin:/usr/games:/home/stas/bin:/home/stas/bin:/usr/local/bin:/usr/X11R6/bin:/usr/java/j2re1.4.0/bin/
PERLDOC_PAGER=less -R
PERL_BADLANG (unset)
SHELL=/bin/tcsh
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
Thread Next
-
[5.8.x segfault + patch] chicken&egg segfault in -Dm -Mthreads
by Stas Bekman