Front page | perl.perl5.porters |
Postings from May 2008
[perl #53962] bug in Time::HiRes 5.11
Thread Next
From:
dk @ tetsuo . karasik . eu . org
Date:
May 11, 2008 05:54
Subject:
[perl #53962] bug in Time::HiRes 5.11
Message ID:
rt-3.6.HEAD-20841-1210446270-47.53962-75-0@perl.org
# New Ticket Created by dk@tetsuo.karasik.eu.org
# Please include the string: [perl #53962]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=53962 >
This is a bug report for perl from dmitry@karasik.eu.org
generated with the help of perlbug 1.36 running under perl 5.11.0.
-----------------------------------------------------------------
[Please enter your report here]
Hello,
There's apparently bad behavior in Time::HiRes alarm code, in 5.11.0 and partly
in 5.10.0 . I hope that I'm wrong, but if I ain't, this seems to me a good
candidate to the daily WTF, because that's how one can accurately describe my
feeling when I saw the source :) The problem is simple:
use Time::HiRes qw(alarm);
my $tick;
$SIG{ALRM} = sub { $tick++ };
alarm(0.5);
sleep(1);
print "caught signal: ", ( $tick ? "ok" : "not ok"), "\n";
I was about to write the long story how many really strange conditions I found
crammed in these two small functions, but instead I'll just send the patch. I
don't have access to perl's source repositary to see the comments behind the
changes, but I see that beginning from 5.10 the strange changes began to
accumulate. I beg anyone interested to just have a look at the state what
ualarm() and alarm() became, to see if you can explain the logic to me.
Anyway, the patch (hopefully) restores the sanity back. The diff is for today's
(10 May) code I've pulled from git://utsl.gen.nz/perl-preview .
--- HiRes.xs.0 2008-05-10 20:02:23.000000000 +0200
+++ HiRes.xs 2008-05-10 20:42:27.000000000 +0200
@@ -925,7 +925,6 @@
CODE:
if (useconds < 0 || uinterval < 0)
croak("Time::HiRes::ualarm(%d, %d): negative time not invented yet", useconds, uinterval);
- if (useconds >= IV_1E6 || uinterval >= IV_1E6)
#if defined(HAS_SETITIMER) && defined(ITIMER_REAL)
{
struct itimerval itv;
@@ -936,11 +935,8 @@
}
}
#else
- croak("Time::HiRes::ualarm(%d, %d): useconds or uinterval equal to or more than %"IVdf, useconds, uinterval, IV_1E6);
-#endif
- else
RETVAL = ualarm(useconds, uinterval);
-
+#endif
OUTPUT:
RETVAL
@@ -954,7 +950,6 @@
{
IV useconds = IV_1E6 * seconds;
IV uinterval = IV_1E6 * interval;
- if (seconds >= IV_1E6 || interval >= IV_1E6)
#if defined(HAS_SETITIMER) && defined(ITIMER_REAL)
{
struct itimerval itv;
@@ -965,8 +960,7 @@
}
}
#else
- RETVAL = (NV)ualarm((IV)(seconds * IV_1E6),
- (IV)(interval * IV_1E6)) / NV_1E6;
+ RETVAL = ((NV) ualarm( useconds, uinterval)) / NV_1E6;
#endif
}
[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
category=core
severity=medium
---
Site configuration information for perl 5.11.0:
Configured by dk at Sat May 10 19:27:14 CEST 2008.
Summary of my perl5 (revision 5 version 11 subversion 0) configuration:
Platform:
osname=freebsd, osvers=6.2-stable, archname=i386-freebsd
uname='freebsd aguirre.karasik.eu.org 6.2-stable freebsd 6.2-stable #10: tue sep 11 19:36:55 cest 2007 root@aguirre.karasik.eu.org:usrobjusrsrcsysaguirre i386 '
config_args=''
hint=recommended, useposix=true, d_sigaction=define
useithreads=undef, usemultiplicity=undef
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=undef, use64bitall=undef, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -I/usr/local/include',
optimize='-O',
cppflags='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -I/usr/local/include'
ccversion='', gccversion='3.4.6 [FreeBSD] 20060305', 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 ='-Wl,-E -L/usr/local/lib'
libpth=/usr/lib /usr/local/lib
libs=-lgdbm -lm -lcrypt -lutil -lc
perllibs=-lm -lcrypt -lutil -lc
libc=, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
cccdlflags='-DPIC -fPIC', lddlflags='-shared -L/usr/local/lib'
Locally applied patches:
DEVEL
---
@INC for perl 5.11.0:
/usr/local/lib/perl5/5.11.0/i386-freebsd
/usr/local/lib/perl5/5.11.0
/usr/local/lib/perl5/site_perl/5.11.0/i386-freebsd
/usr/local/lib/perl5/site_perl/5.11.0
/usr/local/lib/perl5/site_perl
.
---
Environment for perl 5.11.0:
HOME=/home/dk
LANG=ru_RU.KOI8-R
LANGUAGE (unset)
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/home/dk/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/usr/local/site/bin:/usr/local/site/sbin:/home/dk/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/usr/local/site/bin:/usr/local/site/sbin:/home/dk/bin
PERL_BADLANG (unset)
SHELL=/usr/local/bin/zsh
Thread Next
-
[perl #53962] bug in Time::HiRes 5.11
by dk @ tetsuo . karasik . eu . org