Subject: | double free or corruption with threads |
The following code sometime causes a 'double free or corruption'.
Higher probability the more threads running (used 24 to recreate it
quite frequently).
use strict;
use warnings;
use threads;
my $nr_thr = shift || 1;
for (1..$nr_thr) {
threads->create(sub {require IO::Socket::SSL;});
}
while (threads->list()) {
foreach (threads->list()) {
$_->is_joinable() && $_->join();
}
sleep 1;
}
Tested with perl 5.10.1 and 5.12.3, same result.
Workaround is to load IO::Socket::SSL at compile time.
Similar to ticket #43484 on Net-SSLeay??
Crash:
*** glibc detected *** perl: double free or corruption (!prev):
0x00007f7970226300 ***
======= Backtrace: =========
/lib/libc.so.6(+0x775b6)[0x7f7989af75b6]
/lib/libc.so.6(+0x7dbfb)[0x7f7989afdbfb]
/lib/libc.so.6(realloc+0xf0)[0x7f7989afe0b0]
/usr/lib/libcrypto.so.0.9.8(CRYPTO_realloc+0x5f)[0x7f7962a86fdf]
/usr/lib/libcrypto.so.0.9.8(lh_insert+0x177)[0x7f7962ae6cd7]
/usr/lib/libcrypto.so.0.9.8(+0xcf259)[0x7f7962aeb259]
/usr/lib/libcrypto.so.0.9.8(ERR_load_strings+0x41)[0x7f7962aeaa11]
/usr/lib/libcrypto.so.0.9.8(ERR_load_DSA_strings+0x2e)[0x7f7962ad2c1e]
/usr/lib/libcrypto.so.0.9.8(ERR_load_crypto_strings+0x35)[0x7f7962aeb5a5]
/usr/lib/libssl.so.0.9.8(SSL_load_error_strings+0x9)[0x7f7962de2729]
/usr/local/lib/perl5/site_perl/5.12.3/x86_64-linux-thread-multi/auto/Net/SSLeay/SSLeay.so(XS_Net__SSLeay_load_error_strings+0x73)[0x7f79781cd323]
/usr/local/lib/perl5/5.12.3/x86_64-linux-thread-multi/CORE/libperl.so(Perl_pp_entersub+0x530)[0x7f798abac460]
/usr/local/lib/perl5/5.12.3/x86_64-linux-thread-multi/CORE/libperl.so(Perl_runops_standard+0x16)[0x7f798abaaf86]
/usr/local/lib/perl5/5.12.3/x86_64-linux-thread-multi/CORE/libperl.so(Perl_call_sv+0x4c7)[0x7f798ab4e6b7]
/usr/local/lib/perl5/5.12.3/x86_64-linux-thread-multi/CORE/libperl.so(Perl_call_list+0x2cd)[0x7f798ab4ebcd]
/usr/local/lib/perl5/5.12.3/x86_64-linux-thread-multi/CORE/libperl.so(+0x3a649)[0x7f798ab37649]
/usr/local/lib/perl5/5.12.3/x86_64-linux-thread-multi/CORE/libperl.so(Perl_newATTRSUB+0xaa5)[0x7f798ab45ae5]
/usr/local/lib/perl5/5.12.3/x86_64-linux-thread-multi/CORE/libperl.so(Perl_yyparse+0x28a1)[0x7f798ab76241]
/usr/local/lib/perl5/5.12.3/x86_64-linux-thread-multi/CORE/libperl.so(+0xe7199)[0x7f798abe4199]
/usr/local/lib/perl5/5.12.3/x86_64-linux-thread-multi/CORE/libperl.so(Perl_pp_require+0x801)[0x7f798abe59f1]
/usr/local/lib/perl5/5.12.3/x86_64-linux-thread-multi/CORE/libperl.so(Perl_runops_standard+0x16)[0x7f798abaaf86]
/usr/local/lib/perl5/5.12.3/x86_64-linux-thread-multi/CORE/libperl.so(Perl_call_sv+0x4c7)[0x7f798ab4e6b7]
/usr/local/lib/perl5/5.12.3/x86_64-linux-thread-multi/auto/threads/threads.so(+0x7029)[0x7f798987b029]
/lib/libpthread.so.0(+0x69ca)[0x7f7989e099ca]
/lib/libc.so.6(clone+0x6d)[0x7f7989b6670d]
======= Memory map: ========
00400000-00402000 r-xp 00000000 08:01 9313431
/usr/local/bin/perl
00601000-00602000 r--p 00001000 08:01 9313431
/usr/local/bin/perl
00602000-00603000 rw-p 00002000 08:01 9313431
/usr/local/bin/perl
021c3000-026aa000 rw-p 00000000 00:00 0
[heap]
7f7950000000-7f79500bb000 rw-p 00000000 00:00 0
7f79500bb000-7f7954000000 ---p 00000000 00:00 0
7f7958000000-7f7958106000 rw-p 00000000 00:00 0
7f7958106000-7f795c000000 ---p 00000000 00:00 0
7f795c000000-7f795c11a000 rw-p 00000000 00:00 0
7f795c11a000-7f7960000000 ---p 00000000 00:00 0
7f79613e2000-7f79613f8000 r-xp 00000000 08:01 6684751
/lib/libgcc_s.so.1
7f79613f8000-7f79615f7000 ---p 00016000 08:01 6684751
/lib/libgcc_s.so.1
7f79615f7000-7f79615f8000 r--p 00015000 08:01 6684751
/lib/libgcc_s.so.1
7f79615f8000-7f79615f9000 rw-p 00016000 08:01 6684751
/lib/libgcc_s.so.1
7f79615f9000-7f7961602000 r-xp 00000000 08:01 9703531
/usr/local/lib/perl5/5.12.3/x86_64-linux-thread-multi/auto/List/Util/Util.so
7f7961602000-7f7961801000 ---p 00009000 08:01 9703531
/usr/local/lib/perl5/5.12.3/x86_64-linux-thread-multi/auto/List/Util/Util.so
7f7961801000-7f7961802000 r--p 00008000 08:01 9703531
/usr/local/lib/perl5/5.12.3/x86_64-linux-thread-multi/auto/List/Util/Util.so
7f7961802000-7f7961803000 rw-p 00009000 08:01 9703531
/usr/local/lib/perl5/5.12.3/x86_64-linux-thread-multi/auto/List/Util/Util.so
7f7961803000-7f7961804000 ---p 00000000 00:00 0
7f7961804000-7f7962004000 rw-p 00000000 00:00 0
7f7962004000-7f7962005000 ---p 00000000 00:00 0
7f7962005000-7f7962805000 rw-p 00000000 00:00 0
7f7962805000-7f796281b000 r-xp 00000000 08:01 6684866
/lib/libz.so.1.2.3.3
7f796281b000-7f7962a1a000 ---p 00016000 08:01 6684866
/lib/libz.so.1.2.3.3
7f7962a1a000-7f7962a1b000 r--p 00015000 08:01 6684866
/lib/libz.so.1.2.3.3
7f7962a1b000-7f7962a1c000 rw-p 00016000 08:01 6684866
/lib/libz.so.1.2.3.3
7f7962a1c000-7f7962b84000 r-xp 00000000 08:01 6684675
/lib/libcrypto.so.0.9.8
7f7962b84000-7f7962d83000 ---p 00168000 08:01 6684675
/lib/libcrypto.so.0.9.8
7f7962d83000-7f7962d90000 r--p 00167000 08:01 6684675
/lib/libcrypto.so.0.9.8
7f7962d90000-7f7962da8000 rw-p 00174000 08:01 6684675
/lib/libcrypto.so.0.9.8
7f7962da8000-7f7962dac000 rw-p 00000000 00:00 0
7f7962dac000-7f7962df7000 r-xp 00000000 08:01 6684683
/lib/libssl.so.0.9.8
7f7962df7000-7f7962ff6000 ---p 0004b000 08:01 6684683
/lib/libssl.so.0.9.8
7f7962ff6000-7f7962ff8000 r--p 0004a000 08:01 6684683
/lib/libssl.so.0.9.8
7f7962ff8000-7f7962ffd000 rw-p 0004c000 08:01 6684683
/lib/libssl.so.0.9.8
7f7962ffd000-7f7962ffe000 rw-p 00000000 00:00 0
7f7962ffe000-7f7962fff000 ---p 00000000 00:00 0
7f7962fff000-7f79637ff000 rw-p 00000000 00:00 0
7f79637ff000-7f7963800000 ---p 00000000 00:00 0
7f7963800000-7f7964000000 rw-p 00000000 00:00 0
7f7964000000-7f79641d6000 rw-p 00000000 00:00 0
7f79641d6000-7f7968000000 ---p 00000000 00:00 0
7f7968000000-7f7968161000 rw-p 00000000 00:00 0
7f7968161000-7f796c000000 ---p 00000000 00:00 0
7f796c000000-7f796c26b000 rw-p 00000000 00:00 0
7f796c26b000-7f7970000000 ---p 00000000 00:00 0
7f7970000000-7f797022d000 rw-p 00000000 00:00 0
7f797022d000-7f7974000000 ---p 00000000 00:00 0
7f7974000000-7f7974216000 rw-p 00000000 00:00 0
7f7974216000-7f7978000000 ---p 00000000 00:00 0
7f7978195000-7f79781e9000 r-xp 00000000 08:01 10226915
/usr/local/lib/perl5/site_perl/5.12.3/x86_64-linux-thread-multi/auto/Net/SSLeay/SSLeay.so
7f79781e9000-7f79783e9000 ---p 00054000 08:01 10226915
/usr/local/lib/perl5/site_perl/5.12.3/x86_64-linux-thread-multi/auto/Net/SSLeay/SSLeay.so
7f79783e9000-7f79783ea000 r--p 00054000 08:01 10226915
/usr/local/lib/perl5/site_perl/5.12.3/x86_64-linux-thread-multi/auto/Net/SSLeay/SSLeay.soAborted
Environment:
Linux TcmToolslinux2 2.6.32-29-generic #58-Ubuntu SMP Fri Feb 11
20:52:10 UTC 2011 x86_64 GNU/Linux
Site configuration information for perl 5.12.3:
Configured by ericsson at Fri Mar 25 19:51:52 CET 2011.
Summary of my perl5 (revision 5 version 12 subversion 3) configuration:
Platform:
osname=linux, osvers=2.6.32-29-generic,
archname=x86_64-linux-thread-multi
uname='linux tcmtoolslinux2 2.6.32-29-generic #58-ubuntu smp fri feb
11 20:52:10 utc 2011 x86_64 gnulinux '
config_args='-Dusethreads -Duselargefiles -Dccflags=-DDEBIAN
-Dcccdlflags=-fPIC -Uafs -Ud_csh -Ud_ualarm -Uusesfio -Uusenm
-DDEBUGGING=-g -Doptimize=-O2 -Duseshrplib -des'
hint=recommended, useposix=true, d_sigaction=define
useithreads=define, usemultiplicity=define
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=define, use64bitall=define, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DDEBIAN
-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O2 -g',
cppflags='-D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing
-pipe -fstack-protector -I/usr/local/include'
ccversion='', gccversion='4.4.3', gccosandvers=''
intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
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 -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib /lib64 /usr/lib64
libs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
libc=/lib/libc-2.11.1.so, so=so, useshrplib=true, libperl=libperl.so
gnulibc_version='2.11.1'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E
-Wl,-rpath,/usr/local/lib/perl5/5.12.3/x86_64-linux-thread-multi/CORE'
cccdlflags='-fPIC', lddlflags='-shared -O2 -g -L/usr/local/lib
-fstack-protector'
Locally applied patches:
---
@INC for perl 5.12.3:
/usr/local/lib/perl5/site_perl/5.12.3/x86_64-linux-thread-multi
/usr/local/lib/perl5/site_perl/5.12.3
/usr/local/lib/perl5/5.12.3/x86_64-linux-thread-multi
/usr/local/lib/perl5/5.12.3
.
---
Environment for perl 5.12.3:
HOME=/home/ericsson
LANG=en_US.UTF-8
LANGUAGE (unset)
LC_TIME=sv_SE.utf8
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
PERL_BADLANG (unset)
SHELL=/bin/bash