Update of /cvsroot/sbcl/sbcl/tests
In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv22483/tests
Modified Files:
signals.impure.lisp
Log Message:
1.0.42.50: workaround a Darwin nanosleep() bug
Fixes lp#640516.
It turns out that on Darwin, if a nanosleep() call is interrupted,
and the signal handler takes longer than the requested sleep time
was, then the call will return with EINTR and (unsigned)-1 in the
remaining seconds.
Since we call nanosleep() again when it returns with EINTR with the
remaining time, this would cause us to sleep ~136 years...
So, check that the remainder is not increasing before calling
nanosleep() again.
Many, many thanks to Joe Lobraco who reported and diagnosed the
issue.
Index: signals.impure.lisp
===================================================================
RCS file: /cvsroot/sbcl/sbcl/tests/signals.impure.lisp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- signals.impure.lisp 17 Mar 2010 16:51:55 -0000 1.3
+++ signals.impure.lisp 21 Sep 2010 13:10:39 -0000 1.4
@@ -65,3 +65,19 @@
sb-unix:sigint)
(sb-sys:interactive-interrupt ()
:condition)))))
+
+(with-test (:name :bug-640516)
+ ;; On Darwin interrupting a SLEEP so that it took longer than
+ ;; the requested amount caused it to hang.
+ (assert
+ (handler-case
+ (sb-ext:with-timeout 10
+ (let (to)
+ (handler-bind ((sb-ext:timeout (lambda (c)
+ (unless to
+ (setf to t)
+ (sleep 2)
+ (continue c)))))
+ (sb-ext:with-timeout 0.1 (sleep 1) t))))
+ (sb-ext:timeout ()
+ nil))))
|