Subject: | Hanging in leaving context |
Date: | Thu, 14 Jun 2012 13:52:56 +0300 |
To: | bug-threads-shared [...] rt.cpan.org |
From: | Matti Linnanvuori <matti.linnanvuori [...] portalify.com> |
Hi!
I think I have found a bug where a thread hangs when leaving a context and unlocking a locked variable. The code hangs after printing "Unlocking sendable".
[Switching to thread 2 (Thread 0x7f71ab036710 (LWP 13223))]#0 0x00007f71acea90a4 in __lll_lock_wait () from /lib64/libpthread.so.0
(gdb) bt
#0 0x00007f71acea90a4 in __lll_lock_wait () from /lib64/libpthread.so.0
#1 0x00007f71acea4429 in _L_lock_1004 () from /lib64/libpthread.so.0
#2 0x00007f71acea423e in pthread_mutex_lock () from /lib64/libpthread.so.0
#3 0x00007f71ac511cac in recursive_lock_release (my_perl=0x7b7100, lock=0x80)
at shared.xs:200
#4 0x00000000004b7495 in Perl_leave_scope ()
#5 0x000000000047f9aa in Perl_pp_leavesub ()
#6 0x0000000000455ad3 in Perl_runops_debug ()
#7 0x0000000000479430 in Perl_call_sv ()
#8 0x00007f71ac938cf9 in S_ithread_run (arg=<value optimized out>)
at threads.xs:517
#9 0x00007f71acea25f0 in start_thread () from /lib64/libpthread.so.0
#10 0x00007f71acc1184d in clone () from /lib64/libc.so.6
#11 0x0000000000000000 in ?? ()
sub send_line {
my ( $self, $service, $type, $message, @line ) = @_;
logf "Locking sendable";
lock $sendable;
logf "Locked sendable";
if ( my $line = set_ctsds( $service, $type ) ) {
unshift @line, $line;
}
$sendable = shared_clone($message);
my $error;
my $message_reference;
for my $line (@line) {
if ( $message->{'type'} eq 'dispatch'
and substr( $line, 0, 2 ) ne 'AT' )
{
$message_reference = hex( substr $line, 4, 2 );
$message[$message_reference] = $sendable;
}
logf "Locking response";
lock $response;
logf "Locked response";
undef $response;
$error = $self->send($line);
unless ( $error or defined $response ) {
logf "Waiting for response";
if ( cond_timedwait $response, time() + 60 ) {
unless ($response) {
logf "Failed to get a positive response";
return;
}
logf "Got a positive response";
}
else {
$error = 'Timeout';
logf "Got a timeout";
}
}
if ($error) {
logf "Got error $error";
last;
}
logf "Unlocking response";
}
if ( $error and $message->{'type'} eq 'dispatch' ) {
$self->ack( 'transient_failure', $error, $message, $message_reference );
}
logf "Unlocking sendable";
}
threads::shared version 1.40.
perl -V
Summary of my perl5 (revision 5 version 10 subversion 0) configuration:
Platform:
osname=linux, osvers=2.6.32, archname=x86_64-linux-thread-multi
uname='linux knorr 2.6.32 #1 smp 2010-04-12 12:31:11 +0200 x86_64 x86_64 x86_64 gnulinux '
config_args='-ds -e -Dprefix=/usr -Dvendorprefix=/usr -Dinstallusrbinperl -Dusethreads -Di_db -Di_dbm -Di_ndbm -Di_gdbm -Duseshrplib=true -Doptimize=-fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -Wall -pipe -Accflags=-DPERL_USE_SAFE_PUTENV'
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 -DPERL_USE_SAFE_PUTENV -DDEBUGGING -fno-strict-aliasing -pipe -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -Wall -pipe',
cppflags='-D_REENTRANT -D_GNU_SOURCE -DPERL_USE_SAFE_PUTENV -DDEBUGGING -fno-strict-aliasing -pipe'
ccversion='', gccversion='4.3.4 [gcc-4_3-branch revision 152973]', 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 =' -L/usr/local/lib64'
libpth=/lib64 /usr/lib64 /usr/local/lib64
libs=-lm -ldl -lcrypt -lpthread
perllibs=-lm -ldl -lcrypt -lpthread
libc=/lib64/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/lib/perl5/5.10.0/x86_64-linux-thread-multi/CORE'
cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib64'
Characteristics of this binary (from libperl):
Compile-time options: DEBUGGING MULTIPLICITY PERL_DONT_CREATE_GVSV
PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP
PERL_TRACK_MEMPOOL PERL_USE_SAFE_PUTENV
USE_64_BIT_ALL USE_64_BIT_INT USE_ITHREADS
USE_LARGE_FILES USE_PERLIO USE_REENTRANT_API
Built under linux
Compiled at May 6 2010 06:53:26
@INC:
/usr/lib/perl5/5.10.0/x86_64-linux-thread-multi
/usr/lib/perl5/5.10.0
/usr/lib/perl5/site_perl/5.10.0/x86_64-linux-thread-multi
/usr/lib/perl5/site_perl/5.10.0
/usr/lib/perl5/vendor_perl/5.10.0/x86_64-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.10.0
/usr/lib/perl5/vendor_perl
.
Linux iac-sles11sp1 2.6.32.12-0.7-default #1 SMP 2010-05-20 11:14:20 +0200 x86_64 x86_64 x86_64 GNU/Linux
regards, Matti Linnanvuori