Subject: | Log::Dispatch::Syslog isn't thread-safe |
Date: | Fri, 6 May 2011 14:36:06 +0200 (CEST) |
To: | bug-Log-Dispatch [...] rt.cpan.org |
From: | Cedric Carree <cedric.carree [...] mancalanetworks.com> |
Hi.
Using Perl 5.6.0 threads, the Log::Dispatch::Syslog may SEGV. This is maybe a bug on Sys::Syslog rather than Log::Dispatch::Syslog
I think this is because Sys::Syslog tries to open and/or close twice the connection to syslog (in two differents threads).
Here are the traces I got running my test script (attached)
cedric.carree@me:~$ perl syslog-thread.pl
Attempt to free unreferenced scalar: SV 0x916ed78, Perl interpreter: 0x8eb2c68 at /usr/share/perl5/Log/Dispatch/Output.pm line 34.
Thread 3 terminated abnormally: The following parameter was passed in the call to Log::Dispatch::Output::log but was not listed in the validation options: log4p_level
at /usr/share/perl5/Log/Dispatch/Output.pm line 30 thread 3
Log::Dispatch::Output::log(undef, 'level', 1, 'name', 'app001', 'message', 'INFO - In thread 3\x{a}', 'log4p_category', 'thread-test', ...) called at /usr/share/perl5/Log/Log4perl/Appender.pm line 212 thread 3
Log::Log4perl::Appender::log('Log::Log4perl::Appender=HASH(0xb6cd93c8)', 'HASH(0x91d0668)', 'thread-test', 'INFO') called at /usr/share/perl5/Log/Log4perl/Logger.pm line 301 thread 3
Log::Log4perl::Logger::__ANON__('Log::Log4perl::Logger=HASH(0xb6cd8f68)', 'In thread 3') called at /usr/share/perl5/Log/Log4perl/Logger.pm line 782 thread 3
Log::Log4perl::Logger::__ANON__('Log::Log4perl::Logger=HASH(0xb6cd8f68)', 'In thread 3') called at syslog-thread.pl line 34 thread 3
main::log_me(3) called at syslog-thread.pl line 22 thread 3
eval {...} called at syslog-thread.pl line 22 thread 3
Attempt to free unreferenced scalar: SV 0x916ef08, Perl interpreter: 0x8eb2c68 at /usr/share/perl5/Log/Dispatch/Output.pm line 34.
Attempt to free unreferenced scalar: SV 0x91dd898, Perl interpreter: 0x8eb2c68 at /usr/share/perl5/Log/Dispatch/Output.pm line 30.
Attempt to free unreferenced scalar: SV 0x93be410, Perl interpreter: 0x91de938 at /usr/share/perl5/Log/Dispatch/Output.pm line 34.
Attempt to free unreferenced scalar: SV 0x9754128, Perl interpreter: 0x916fc98 at /usr/share/perl5/Log/Dispatch/Output.pm line 34.
Attempt to free unreferenced scalar: SV 0x916ecb8, Perl interpreter: 0x937c2e0 at /usr/share/perl5/Log/Dispatch/Output.pm line 34.
Attempt to free unreferenced scalar: SV 0x916e9c8, Perl interpreter: 0x8eb2c68 at /usr/share/perl5/Log/Dispatch/Output.pm line 34.
Attempt to free unreferenced scalar: SV 0xb6b83d20, Perl interpreter: 0x937c2e0 at /usr/share/perl5/Log/Dispatch/Output.pm line 34.
Attempt to free unreferenced scalar: SV 0xb6b83d20, Perl interpreter: 0x937c2e0 at /usr/share/perl5/Log/Dispatch/Output.pm line 34.
Attempt to free unreferenced scalar: SV 0x916ec88, Perl interpreter: 0x91de938 at /usr/share/perl5/Log/Dispatch/Output.pm line 30.
Thread 4 terminated abnormally: The following parameter was passed in the call to Log::Dispatch::Output::log but was not listed in the validation options: log4p_level
at /usr/share/perl5/Log/Dispatch/Output.pm line 30 thread 4
Log::Dispatch::Output::log(undef, 'level', 1, 'name', 'app001', 'message', 'INFO - In thread 4\x{a}', 'log4p_category', 'thread-test', ...) called at /usr/share/perl5/Log/Log4perl/Appender.pm line 212 thread 4
Log::Log4perl::Appender::log('Log::Log4perl::Appender=HASH(0x9308828)', 'HASH(0x93be1a0)', 'thread-test', 'INFO') called at /usr/share/perl5/Log/Log4perl/Logger.pm line 301 thread 4
Log::Log4perl::Logger::__ANON__('Log::Log4perl::Logger=HASH(0x93083c8)', 'In thread 4') called at /usr/share/perl5/Log/Log4perl/Logger.pm line 782 thread 4
Log::Log4perl::Logger::__ANON__('Log::Log4perl::Logger=HASH(0x93083c8)', 'In thread 4') called at syslog-thread.pl line 34 thread 4
main::log_me(4) called at syslog-thread.pl line 22 thread 4
eval {...} called at syslog-thread.pl line 22 thread 4
Attempt to free unreferenced scalar: SV 0xb6b83c40, Perl interpreter: 0x916fc98 at /usr/share/perl5/Log/Dispatch/Output.pm line 34.
Attempt to free unreferenced scalar: SV 0x9584b50, Perl interpreter: 0x8eb2c68 at /usr/share/perl5/Log/Dispatch/Output.pm line 34.
Attempt to free unreferenced scalar: SV 0xb6b83d60, Perl interpreter: 0x8eb2c68 at /usr/share/perl5/Log/Dispatch/Output.pm line 30.
Attempt to free unreferenced scalar: SV 0xb6b83ef0, Perl interpreter: 0x916fc98 at /usr/share/perl5/Log/Dispatch/Output.pm line 30.
Thread 1 terminated abnormally: The following parameter was passed in the call to Log::Dispatch::Output::log but was not listed in the validation options: log4p_level
at /usr/share/perl5/Log/Dispatch/Output.pm line 30 thread 1
Log::Dispatch::Output::log(undef, 'level', 1, 'name', 'app001', 'message', 'INFO - In thread 1\x{a}', 'log4p_category', 'thread-test', ...) called at /usr/share/perl5/Log/Log4perl/Appender.pm line 212 thread 1
Log::Log4perl::Appender::log('Log::Log4perl::Appender=HASH(0x90d9070)', 'HASH(0x916e8a8)', 'thread-test', 'INFO') called at /usr/share/perl5/Log/Log4perl/Logger.pm line 301 thread 1
Log::Log4perl::Logger::__ANON__('Log::Log4perl::Logger=HASH(0x90d8c10)', 'In thread 1') called at /usr/share/perl5/Log/Log4perl/Logger.pm line 782 thread 1
Log::Log4perl::Logger::__ANON__('Log::Log4perl::Logger=HASH(0x90d8c10)', 'In thread 1') called at syslog-thread.pl line 34 thread 1
main::log_me(1) called at syslog-thread.pl line 22 thread 1
eval {...} called at syslog-thread.pl line 22 thread 1
Thread 2 terminated abnormally: The following parameter was passed in the call to Log::Dispatch::Output::log but was not listed in the validation options: log4p_level
at /usr/share/perl5/Log/Dispatch/Output.pm line 30 thread 2
Log::Dispatch::Output::log(undef, 'level', 1, 'name', 'app001', 'message', 'INFO - In thread 2\x{a}', 'log4p_category', 'thread-test', ...) called at /usr/share/perl5/Log/Log4perl/Appender.pm line 212 thread 2
Log::Log4perl::Appender::log('Log::Log4perl::Appender=HASH(0xb6dee720)', 'HASH(0xb6b83990)', 'thread-test', 'INFO') called at /usr/share/perl5/Log/Log4perl/Logger.pm line 301 thread 2
Log::Log4perl::Logger::__ANON__('Log::Log4perl::Logger=HASH(0xb6dee2c0)', 'In thread 2') called at /usr/share/perl5/Log/Log4perl/Logger.pm line 782 thread 2
Log::Log4perl::Logger::__ANON__('Log::Log4perl::Logger=HASH(0xb6dee2c0)', 'In thread 2') called at syslog-thread.pl line 34 thread 2
main::log_me(2) called at syslog-thread.pl line 22 thread 2
eval {...} called at syslog-thread.pl line 22 thread 2
Segmentation fault
my system is (uname -a)
Linux lindesktop21 2.6.32-31-generic #61-Ubuntu SMP Fri Apr 8 18:24:35 UTC 2011 i686 GNU/Linux
My Perl version is
Summary of my perl5 (revision 5 version 10 subversion 1) configuration:
Platform:
osname=linux, osvers=2.6.24-28-server, archname=i486-linux-gnu-thread-multi
uname='linux roseapple 2.6.24-28-server #1 smp wed aug 18 21:17:51 utc 2010 i686 gnulinux '
config_args='-Dusethreads -Duselargefiles -Dccflags=-DDEBIAN -Dcccdlflags=-fPIC -Darchname=i486-linux-gnu -Dprefix=/usr -Dprivlib=/usr/share/perl/5.10 -Darchlib=/usr/lib/perl/5.10 -Dvendorprefix=/usr -Dvendorlib=/usr/share/perl5 -Dvendorarch=/usr/lib/perl5 -Dsiteprefix=/usr/local -Dsitelib=/usr/local/share/perl/5.10.1 -Dsitearch=/usr/local/lib/perl/5.10.1 -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Dsiteman3dir=/usr/local/man/man3 -Dman1ext=1 -Dman3ext=3perl -Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh -Ud_ualarm -Uusesfio -Uusenm -DDEBUGGING=-g -Doptimize=-O2 -Duseshrplib -Dlibperl=libperl.so.5.10.1 -Dd_dosuid -des'
hint=recommended, useposix=true, d_sigaction=define
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 -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=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 =' -fstack-protector -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib /usr/lib64
libs=-lgdbm -lgdbm_compat -ldb -ldl -lm -lpthread -lc -lcrypt
perllibs=-ldl -lm -lpthread -lc -lcrypt
libc=/lib/libc-2.11.1.so, so=so, useshrplib=true, libperl=libperl.so.5.10.1
gnulibc_version='2.11.1'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
cccdlflags='-fPIC', lddlflags='-shared -O2 -g -L/usr/local/lib -fstack-protector'
Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY PERL_DONT_CREATE_GVSV
PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP USE_ITHREADS
USE_LARGE_FILES USE_PERLIO USE_REENTRANT_API
Built under linux
Compiled at Apr 22 2011 18:17:20
@INC:
/etc/perl
/usr/local/lib/perl/5.10.1
/usr/local/share/perl/5.10.1
/usr/lib/perl5
/usr/share/perl5
/usr/lib/perl/5.10
/usr/share/perl/5.10
/usr/local/lib/site_perl
I attached a patch. It loads the threads module if Perl was compiled with the ithreads options, then it locks before openning connection to syslog.
Best regards
Cedric
Message body is not shown because it is too large.
Message body is not shown because sender requested not to inline it.
Message body is not shown because sender requested not to inline it.