develooper Front page | perl.perl5.porters | Postings from May 2012

[perl #37460] system() in threads causes segmentation fault

Thread Previous
From:
Brian Fraser via RT
Date:
May 24, 2012 19:23
Subject:
[perl #37460] system() in threads causes segmentation fault
Message ID:
rt-3.6.HEAD-7788-1337912579-1982.37460-15-0@perl.org
On Mon Oct 17 06:31:55 2005, t-ikegami@aist.go.jp wrote:
> This is a bug report for perl from ikegami@fsvc001.asc.hpcc.jp,
> generated with the help of perlbug 1.35 running under perl v5.8.7.
> 
> 
> -----------------------------------------------------------------
> [Please enter your report here]
> 
> With perl 5.8.7 running under Linux 2.4, the following code ends up
> with segmentation fault.
> 
> 	#!/usr/bin/perl
> 	use strict;
> 	use warnings;
> 	use threads;
> 	use threads::shared;
> 
> 	while(1) {
> 	  my @t;
> 	  for (1..20) {
> 	    push @t, async {
> 	      system("ls -l /etc > /dev/null");
> 	      return;
> 	    };
> 	  }
> 	  $_->join for @t;
> 	  print ".";
> 	}
> 
> The symptom is highly stochastic; the number of "." printed before the
> segmentation fault indicates the stability.  The instability is most
> prominent on dual Xeon (3 GHz) machine with Linux 2.4.24 + libc 2.3.2,
> but it can be noticed on Pentium III (800 MHz) + Linux 2.4.18-3 + libc
> 2.2.5 and Dual Opteron (2 GHz) + Linux 2.4.21-251-smp + libc 2.2.5.
> 
> The symptom seems not to be observed on Linux 2.6 machine (Dual
> Opteron (2 GHz) + Linux 2.6.5-7.191-smp + libc 2.3.3, for example),
> but instead, the following code blocks.
> 
> 	#!/usr/bin/perl
> 	use strict;
> 	use warnings;
> 	use threads;
> 	use threads::shared;
> 	use FileHandle;
> 
> 	my $str = "x" x 8192;
> 
> 	while(1) {
> 	  my @t;
> 	  for (1..20) {
> 	    push @t, async {
> 	      my $H = new FileHandle "| cat > /dev/null"	or die;
> 	      print $H $str;
> 	      close $H;
> 	      return;
> 	    };
> 	  }
> 	  $_->join for @t;
> 	  print ".";
> 	}
> 
> It occurs far less frequent, but some threads happens to be blocked at
> "new FileHandle" line.  Note that the above code, when running on
> Linux 2.4, sometimes causes segmentation fault, and sometimes blocks.
> 
> It is not certain, but with perl 5.8.6, the symptom is not observed so
> far.
> 
> 
> Stack trace after the segmentation fault with the first code goes like
> this:
> 
> 	Program received signal SIGSEGV, Segmentation fault.
> 	0x4009eff0 in sem_unlink () from /lib/i686/libpthread.so.0
> 	(gdb) where
> 	#0  0x4009eff0 in sem_unlink () from /lib/i686/libpthread.so.0
> 	#1  0x4009bf2c in pthread_mutex_unlock () from
>    /lib/i686/libpthread.so.0
> 	#2  0x42078788 in posix_memalign () from /lib/i686/libc.so.6
> 	#3  0x42075b85 in free () from /lib/i686/libc.so.6
> 	#4  0x080d3df9 in Perl_ptr_table_free ()
> 	#5  0x4001759f in Perl_ithread_create ()
> 	   from /work/ikegami/perl/lib/5.8.7/i686-linux-thread-
>    multi/auto/threads/threads.so
> 	#6  0x40017de5 in XS_threads_new ()
> 	   from /work/ikegami/perl/lib/5.8.7/i686-linux-thread-
>    multi/auto/threads/threads.so
> 	#7  0x080ef5be in Perl_pp_goto ()
> 	#8  0x080bc359 in Perl_runops_standard ()
> 	#9  0x08063948 in S_run_body ()
> 	#10 0x08063755 in perl_run ()
> 	#11 0x0805fddd in main ()
> 
> and in another run:
> 
> 	Program received signal SIGSEGV, Segmentation fault.
> 	0x4009eff0 in sem_unlink () from /lib/i686/libpthread.so.0
> 	(gdb) where
> 	#0  0x4009eff0 in sem_unlink () from /lib/i686/libpthread.so.0
> 	#1  0x4009bf2c in pthread_mutex_unlock () from
>    /lib/i686/libpthread.so.0
> 	#2  0x42078788 in posix_memalign () from /lib/i686/libc.so.6
> 	#3  0x42075b85 in free () from /lib/i686/libc.so.6
> 	#4  0x080cc3e0 in Perl_sv_clear ()
> 	#5  0x080cc7e0 in Perl_sv_free ()
> 	#6  0x080e7051 in Perl_free_tmps ()
> 	#7  0x080bc8ba in Perl_pp_unstack ()
> 	#8  0x080bc359 in Perl_runops_standard ()
> 	#9  0x08063948 in S_run_body ()
> 	#10 0x08063755 in perl_run ()
> 	#11 0x0805fddd in main ()
> 
> And in other cases, stack seems to be corrupted.
> 
> [Please do not change anything below this line]
> -----------------------------------------------------------------
> ---
> Flags:
>     category=core
>     severity=medium
> ---
> Site configuration information for perl v5.8.7:
> 
> Configured by ikegami at Thu Jun 16 15:10:02 JST 2005.
> 
> Summary of my perl5 (revision 5 version 8 subversion 7) configuration:
>   Platform:
>     osname=linux, osvers=2.4.24-bluesmoke-dvd, archname=i686-linux-
>    thread-multi
>     uname='linux fsvc001 2.4.24-bluesmoke-dvd #5 smp thu mar 11
>    12:28:01 jst 2004 i686 i686 i386 gnulinux '
>     config_args='-ds -e -Dprefix=/work/ikegami/perl -Dusethreads'
>     hint=recommended, useposix=true, d_sigaction=define
>     usethreads=define use5005threads=undef useithreads=define
>    usemultiplicity=define
>     useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
>     use64bitint=undef use64bitall=undef uselongdouble=undef
>     usemymalloc=n, bincompat5005=undef
>   Compiler:
>     cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS
>    -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE
>    -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
>     optimize='-O2',
>     cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS
>    -fno-strict-aliasing -pipe -I/usr/local/include
>    -I/usr/include/gdbm'
>     ccversion='', gccversion='3.3.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='cc', ldflags =' -L/usr/local/lib'
>     libpth=/usr/local/lib /lib /usr/lib
>     libs=-lnsl -lgdbm -ldl -lm -lcrypt -lutil -lpthread -lc
>     perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -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.7:
>     /work/ikegami/perl/lib/5.8.7/i686-linux-thread-multi
>     /work/ikegami/perl/lib/5.8.7
>     /work/ikegami/perl/lib/site_perl/5.8.7/i686-linux-thread-multi
>     /work/ikegami/perl/lib/site_perl/5.8.7
>     /work/ikegami/perl/lib/site_perl
>     .
> 
> ---
> Environment for perl v5.8.7:
>     HOME=/home/ikegami
>     LANG=ja_JP.eucJP
>     LANGUAGE (unset)
>     LD_LIBRARY_PATH (unset)
>     LOGDIR (unset)
>     PATH=/usr/local/SGE/sge-6_0u1/bin/lx24-
>   
x86:/usr/pgi/linux86/5.2/bin:/usr/local/ngv2/bin:/opt/intel_fc_80/bin:/opt/intel_idb_73/bin:/opt/intel_cc_80/bin:/usr/local/gt/bin:/usr/local/gt/sbin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin
>     PERL_BADLANG (unset)
>     SHELL=/bin/bash

I can't reproduce this, but I'm testing on rather different
architectures. Is this still an issue on recent Perls?


---
via perlbug:  queue: perl5 status: new
https://rt.perl.org:443/rt3/Ticket/Display.html?id=37460

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About