Skip Menu |

This queue is for tickets about the Sys-SigAction CPAN distribution.

Report information
The Basics
Id: 39599
Status: resolved
Priority: 0/
Queue: Sys-SigAction

People
Owner: lab [...] lincolnbaxter.com.MAKE.ME.VALID
Requestors: rybskej [...] yahoo.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.10
Fixed in: (no value)



The 'safe' flag is not correctly implemented. According to the POSIX documentation (http://perldoc.perl.org/5.8.8/POSIX.html#POSIX%3a%3aSigSet), the safe flag is manipulated via an accessor function: $sigaction = POSIX::SigAction->new( ... ); $sigaction->safe(1); In a few scripts I've been working on, I was getting sporadic segfaults and occasional memory corruption, and narrowed it down to my a custom CHLD handler installed using Sys::SigAction, as such: sub REAPER { ... } set_sig_handler('CHLD', \&REAPER, { flags => &POSIX::SA_NOCLDSTOP | &POSIX::SA_RESTART, mask => ['CHLD'], safe => $] < 5.008002 ? 0 : 1 }); When setting the handler via %SIG, like $SIG{CHLD} = \&REAPER, the application never encountered any issues. I toyed around with all possible combinations until I identified that the safe flag was being ignored. I applied the attached patch (SigAction.patch) to SigAction.pm, and all the segfaults and other issues disappeared. Thus, I concluded that (at least on MacOS 10.5 platform) the safe flag is not applied unless set via the accessor method. Also, at least on my platform, signals are not safe unless explicitly declared as such when using Sys::SigAction. Platform details are included in perl- platform.txt. Regards, Eric
Subject: SigAction.patch
--- /Library/Perl/5.8.8/Sys/SigAction.pm.orig 2006-10-24 20:08:39.000000000 -0400 +++ /Library/Perl/5.8.8/Sys/SigAction.pm 2008-09-24 22:37:20.000000000 -0400 @@ -106,6 +106,7 @@ my $mask = POSIX::SigSet->new( @siglist ); my $act = POSIX::SigAction->new( $handler ,$mask ,$attrs->{flags} ); +# $act->safe($attrs->{safe}) if defined $attrs->{safe}; return $act; }
Subject: perl-platform.txt
Summary of my perl5 (revision 5 version 8 subversion 8) configuration: Platform: osname=darwin, osvers=9.0, archname=darwin-thread-multi-2level uname='darwin b70.apple.com 9.0 darwin kernel version 9.0.0: mon dec 3 11:36:03 pst 2007; root:xnu-1228.0.1~4release_i386 i386 ' config_args='-ds -e -Dprefix=/usr -Dccflags=-g -pipe -Dldflags=-Dman3ext=3pm -Duseithreads -Duseshrplib' 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=define use64bitall=define uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-arch i386 -arch ppc -g -pipe -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -Wdeclaration-after-statement -I/usr/local/include', optimize='-O3', cppflags='-no-cpp-precomp -g -pipe -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -Wdeclaration-after-statement -I/usr/local/include' ccversion='', gccversion='4.0.1 (Apple Inc. build 5465)', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='cc -mmacosx-version-min=10.5.1', ldflags ='-arch i386 -arch ppc -L/usr/local/lib' libpth=/usr/local/lib /usr/lib libs=-ldbm -ldl -lm -lutil -lc perllibs=-ldl -lm -lutil -lc libc=/usr/lib/libc.dylib, so=dylib, useshrplib=true, libperl=libperl.dylib gnulibc_version='' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags='-arch i386 -arch ppc -bundle -undefined dynamic_lookup -L/usr/local/lib' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP USE_ITHREADS USE_LARGE_FILES USE_PERLIO USE_REENTRANT_API Locally applied patches: fix for regcomp CVE-2007-5116 security vulnerability Built under darwin Compiled at Jan 13 2008 20:35:11 %ENV: PERL5LIB="/sw/lib/perl5:/sw/lib/perl5/darwin" @INC: /sw/lib/perl5 /sw/lib/perl5/darwin /System/Library/Perl/5.8.8/darwin-thread-multi-2level /System/Library/Perl/5.8.8 /Library/Perl/5.8.8/darwin-thread-multi-2level /Library/Perl/5.8.8 /Library/Perl /Network/Library/Perl/5.8.8/darwin-thread-multi-2level /Network/Library/Perl/5.8.8 /Network/Library/Perl /System/Library/Perl/Extras/5.8.8/darwin-thread-multi-2level /System/Library/Perl/Extras/5.8.8 /Library/Perl/5.8.6 /Library/Perl/5.8.1 .
Subject: sigaction 'safe' flag is not correctly implemented.
Appears I neglected to enter a subject for the RT ticket. Sorry about that.