ndwg has asked for the wisdom of the Perl Monks concerning the following question:

Greetings Monks,

I'm looking for guidance on why upgrading a Perl RPM would have broken alarm() functionality, and what to do to fix it.

On a SuSE Linux 9.1 (i586) system, with the latest available perl RPM installed (perl-5.8.3-32.9.i586.rpm), the test code below does not work as expected. The script should print the numbers 1 through 5, catch the alarm, and exit. However, it continues looping until killed with CTRL-C.

The test code works as expected on multiple other platforms and perl versions, including "SuSE Linux 9.1 (x86-64)" with the same perl RPM version installed.

I am almost certain that this functionality worked with the original system install (perl-5.8.3-32.i586.rpm). Due to site security policies, and a published vulnerability in the original perl RPM, we are unable to downgrade perl to the original version. We would like to stick to vendor-supported RPMs, rather than building Perl from source... but SuSE doesn't seem to be supporting 9.1 any more.

Is there something wrong with my test case?
Is this a known problem?
Are there any workarounds?
What are the chances that the update RPM from SuSE-9.3 (perl-5.8.6-5.3.i586.rpm) will work with the other ~40 perl RPMs that are installed?

Thanks for your wisdom,
Nathan

------------------ perl_alarm_test.pl -------------------- #!/usr/bin/perl my $time = shift; defined $time or $time = 5; $SIG{ALRM} = sub { $last = 1; }; $SIG{INT} = sub { $last = 1; }; alarm $time; $last=0; $index=0; while ($last eq 0) { sleep 1; $index=$index+1; print "$index\n"; } $SIG{INT} = undef; exit; -----------------------------------------------------------

Perl version information...

# perl -V Summary of my perl5 (revision 5.0 version 8 subversion 3) configuratio +n: Platform: osname=linux, osvers=2.6.4, archname=i586-linux-thread-multi uname='linux f195 2.6.4 #1 smp tue nov 29 14:32:29 utc 2005 i686 i +686 i386 gnulinux ' config_args='-ds -e -Dprefix=/usr -Dvendorprefix=/usr -Dinstallusr +binperl -Dusethreads -Di_db -Di_dbm -Di_ndbm -Di_gdbm -Duseshrplib=tr +ue -Doptimize=-O2 -march=i586 -mcpu=i686 -fmessage-length=0 -Wall -Wa +ll -pipe' hint=recommended, useposix=true, d_sigaction=define usethreads=define use5005threads=undef useithreads=define usemulti +plicity=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 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O2 -march=i586 -mcpu=i686 -fmessage-length=0 -Wall -Wal +l -pipe', cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fno-stri +ct-aliasing' ccversion='', gccversion='3.3.3 (SuSE Linux)', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=1 +2 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', + lseeksize=8 alignbytes=4, prototype=define Linker and Libraries: ld='cc', ldflags ='' libpth=/lib /usr/lib /usr/local/lib libs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc libc=, so=so, useshrplib=true, libperl=libperl.so gnulibc_version='2.3.3' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynami +c -Wl,-rpath,/usr/lib/perl5/5.8.3/i586-linux-thread-multi/CORE' cccdlflags='-fPIC', lddlflags='-shared' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES PERL +_IMPLICIT_CONTEXT Locally applied patches: SPRINTF0 - fixes for sprintf formatting issues - CVE-2005-3962 Built under linux Compiled at Dec 17 2005 03:22:07 @INC: /usr/lib/perl5/5.8.3/i586-linux-thread-multi /usr/lib/perl5/5.8.3 /usr/lib/perl5/site_perl/5.8.3/i586-linux-thread-multi /usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.3/i586-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.3 /usr/lib/perl5/vendor_perl . # rpm -qi perl-5.8.3-32.9 Name : perl Relocations: (not relocatab +le) Version : 5.8.3 Vendor: SuSE Linux AG, + Nuernberg, Germany Release : 32.9 Build Date: Sat Dec 17 03: +32:43 2005 Install date: Mon Mar 12 17:55:19 2007 Build Host: f195.suse.de Group : Development/Languages/Perl Source RPM: perl-5.8.3-32. +9.src.rpm Size : 36585954 License: GPL, Artistic +License Signature : DSA/SHA1, Sat Dec 17 03:34:46 2005, Key ID a84edae89c800 +aca Packager : http://www.suse.de/feedback Summary : The Perl interpreter

Replies are listed 'Best First'.
Re: Perl RPM upgrade breaks alarm() on SuSE-9.1-i386
by Anno (Deacon) on Mar 28, 2007 at 16:29 UTC
    Is there something wrong with my test case?

    Yes, you're running without strict :)

    In your SIGINT handler you are setting the variable $main::last. The loop queries the lecical $last.

    Anno

    Update: Sorry, scratch it all. I saw a "my" declaration in your code where there was none.

      The user doesn't declare a lexical variable $last, so the while condition is looking at $main::last.

      I would recommend building your own perl and installing it in /usr/local, or some other location that will not interfere with the system's perl installation. It is easy (Configure -des; make test; sudo make install).

      Installing an rpm package that was built for a different version of the os is asking for trouble.

      -Colin.

      WHITEPAGES.COM | INC