Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[perl #16807] getting alarm() to work within threads

11 views
Skip to first unread message

Elizabeth Mattijsen

unread,
Aug 28, 2002, 5:01:40 AM8/28/02
to bugs-bi...@netlabs.develooper.com
# New Ticket Created by Elizabeth Mattijsen
# Please include the string: [perl #16807]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=16807 >


This is a bug report for perl from l...@dijkmat.nl,
generated with the help of perlbug 1.34 running under perl v5.8.0.

-----------------------------------------------------------------
[Please enter your report here]

If you try to do alarms within a thread, and $SIG{ALRM} was not
assigned in the main thread previously, an alarm() that goes
off in the thread will bomb the program completely with the
mysterious message

Alarm clock

being sent to STDERR. It bombs in such a way that I'm not able
to get valgrind to give me a trace (yet).

This behaviour can be circumvented by assigning $SIG{ALRM} with
something (except the empty string) in the main thread before
the thread starts.

Further investigations reveal that assigning in a surrounding
thread that is not the main thread, does _not_ work, it _must_
be the main thread. However, other threads _may_ be running
before the $SIG{ALRM} is set in the main thread, but of course
these threads can not use alarm() reliably then.

This shows it all:

== alarm ========================================================
use threads;
$SIG{ALRM} = 'a' if @ARGV; # must assign outside of threads
threads->new( sub {
$SIG{ALRM} = sub { die "alarm went off properly\n" };
eval {
alarm( 3 );
1 while 1;
alarm( 0 );
};
warn "\$\@ = $@";
} )->join;
=================================================================

$ perl alarm 1
$@ = alarm went off properly

$ perl alarm
Alarm clock

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
category=core
severity=medium
---
Site configuration information for perl v5.8.0:

Configured by liz at Tue Aug 20 12:44:35 CEST 2002.

Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
Platform:
osname=linux, osvers=2.4.18, archname=i686-linux-thread-multi
uname='linux echt.dijkmat.nl 2.4.18 #8 smp mon mar 25 22:28:36 cet
2002 i686 unknown '
config_args='-de -Dusethreads'
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=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
-I/usr/include/gdbm',
optimize='-O2',
cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing
-I/usr/local/include -I/usr/include/gdbm'
ccversion='', gccversion='2.96 20000731 (Red Hat Linux 7.1 2.96-98)',
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 =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -lgdbm -ldb -ldl -lm -lpthread -lc -lcrypt -lutil
perllibs=-lnsl -ldl -lm -lpthread -lc -lcrypt -lutil
libc=/lib/libc-2.2.4.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.2.4'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:


---
@INC for perl v5.8.0:
/usr/local/lib/perl5/5.8.0/i686-linux-thread-multi
/usr/local/lib/perl5/5.8.0
/usr/local/lib/perl5/site_perl/5.8.0/i686-linux-thread-multi
/usr/local/lib/perl5/site_perl/5.8.0
/usr/local/lib/perl5/site_perl/5.7.3
/usr/local/lib/perl5/site_perl
.

---
Environment for perl v5.8.0:
HOME=/home/liz
LANG=en_US
LANGUAGE (unset)
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/liz/bin
PERL_BADLANG (unset)
SHELL=/bin/bash


0 new messages