Integer overflow on struct timespec

zundae$B$H?=$7$^$9e(B

e$B?H6a$K!"e(Bstruct
timespece$B$Ne(Btv_sece$B$,e(B4e$B%P%$%H$G!“e(Bstruct timevale$B$Ne(B
tv_sece$B$,e(B8e$B%P%$%H$N%7%9%F%`$,$”$j$^$9!#$3$N$h$&$J4D6-$G$Oe(B
ruby-1.9.0-0e$B$Ne(B make
teste$B$,e(Btest_thread.rbe$B$G<:GT$7$^$9!#e(B(e$B>:Y$Oe(B
http://zunda.freeshell.org/d/20071227.html#p02 e$B$r$4Mw$/[email protected]$5$$e(B)
e$B<:GT$O2<5-$N$h$&$J%3!<%I$G$b:F8=$G$-$^$9!#e(B

$ uname -srm
NetBSD 3.0.2_PATCH alpha
$ rm -f thread.o
$ make cflags=-DTHREAD_DEBUG miniruby
$ ./miniruby -e ‘Thread.new{}.join(1000000000)’
0x1ffe00000 - create: 0x1203a5800 (0)0x1ffe00000 - thread_join (thid:
0x162e00000)
0x1ffe00000 - native_sleep 999999999
0x1ffe00000 - native_sleep: pthread_cond_timedwait start (-2096164855,
18650000)
miniruby: Error detected by libpthread: Invalid wait time.
Detected by file
“/home/builds/ab/netbsd-3-1-RELEASE/src/lib/libpthread/pthread_cond.c”,
line 186,
function “pthread_cond_timedwait”.
See pthread(3) for information.
Abort trap

e$B$3$N%(%i!<$N860x$O!"e(Bthread_pthread.ce$B$Ne(B412e$B9TL$NB-$7;;e(B(e$B:8JU$,e(B
struct timespece$B!"1&JU$Oe(B2e$B$D$H$be(Bsruct timeval)
ts.tv_sec = tvn.tv_sec + tv->tv_sec;
e$B$,%*!<%P!<%U%m!<$7$F$$$k$?$a$H;W$$$^$9!#<j85$G$O2<5-$N%Q%C%A$Ge(B
make teste$B$,@.8y$9$k$h$&$K$J$j$^$7$?!#e(B

Index: thread_pthread.c

— thread_pthread.c (revision 14793)
+++ thread_pthread.c (working copy)
@@ -432,7 +432,7 @@
thread_debug(“native_sleep: interrupted before sleep\n”);
}
else {

  •  if (tv == 0) {
    
  •  if (tv == 0 || ts.tv_sec < tvn.tv_sec /* overflow */ ) {
    
    thread_debug(“native_sleep: pthread_cond_wait start\n”);
    pthread_cond_wait(&th->native_thread_data.sleep_cond,
    &th->interrupt_lock);

e$BI,[email protected]$r$*4j$$$7$^$9!#e(B

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs