Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#657 closed defect (fixed)

:proc aborts threads waiting on a semaphore in a timed manner

Reported by: ragerdl Owned by: gb
Priority: normal Milestone:
Component: Runtime (threads, GC) Version: trunk
Keywords: Cc: ragerdl@…, gb@…

Description

Hello,

When waiting on a semaphore with a timeout (via the function timed-wait-on-semaphore), if you issue a :proc from the listener thread, it interrupts the thread waiting on the semaphore in a way that causes the thread to abort the waiting.

It still runs the unwind portion of the unwind-protect. Perhaps the printing of the thread via :proc causes an interrupt that's incorrectly handled?

This is on 64 bit Ubuntu with kernel 2.6.24.6+desktop10+25.63

The following script reproduces the problem on the updated version of CCL 1.4. The problem also exhibits itself in 1.3. Does running the script in your own environments allow you to duplicate the problem, and can it be fixed?

Thanks!

(defvar *sem* (ccl:make-semaphore)) (ccl:process-run-function "sadf"

(lambda ()

(unwind-protect

(ccl:timed-wait-on-semaphore *sem* 20)

(print "unwinding"))))

(sleep 1) :proc

Change History (6)

comment:1 Changed 10 years ago by gb

  • Resolution set to fixed
  • Status changed from new to closed

TIMED-WAIT-ON-SEMAPHORE can get interrupted, but is supposed to notice that and resume the wait.

Ah. In CCL::%TIMED-WAIT-ON-SEMAPHORE-PTR, "stop" is calculated incorrectly

Index: level-1/linux-files.lisp
===================================================================
--- level-1/linux-files.lisp	(revision 13405)
+++ level-1/linux-files.lisp	(working copy)
@@ -135,7 +135,7 @@
         (multiple-value-bind (secs millis) (milliseconds duration)
           (let* ((now (get-internal-real-time))
                  (stop (+ now
-                          (* secs 1000)
+                          (* secs internal-time-units-per-second)
                           millis)))
             (loop
               (multiple-value-bind (success err)

Fixed in r13414.

comment:2 Changed 10 years ago by ragerdl

Is there a reason that this behavior is still acting broken? The version I got a few minutes ago is 13416, as the script below shows.

Thanks~

<snip>/ccl$ ccl64 Welcome to Clozure Common Lisp Version 1.4-r13416M (LinuxX8664)! ? (defvar *sem* (ccl:make-semaphore)) (ccl:process-run-function "sadf"

(lambda ()

(unwind-protect

(ccl:timed-wait-on-semaphore *sem* 20)

(print "unwinding"))))

(sleep 1) :proc

*SEM* ? #<PROCESS sadf(2) [Reset] #x3000411A25CD> ? NIL ? "unwinding" 2 : sadf [Semaphore timed wait] (Suspended) 1 : -> listener [Active] 0 : Initial [Sleep] ? :proc 1 : -> listener [Active] 0 : Initial [Sleep]

comment:3 Changed 10 years ago by gb

  • Resolution fixed deleted
  • Status changed from closed to reopened

I'm sure that there is a reason, but I don't know what it is; I see the expected behavior on Darwin and Linux (so far).

comment:4 Changed 10 years ago by rme

The fixes are only in the trunk. From the version string "Clozure Common Lisp Version 1.4-r13416M (LinuxX8664)" we see that ragerdl is using the 1.4 release branch; the fixes haven't been ported there yet.

comment:5 Changed 10 years ago by ragerdl

  • Resolution set to fixed
  • Status changed from reopened to closed

Okay, I'll check out a dev copy. Thanks.

comment:6 Changed 10 years ago by rme

(In [13424]) Port r13414, r13415 (replace hardwired 1000 with INTERNAL-TIME-UNITS-PER-SECOND in %TIMED-WAIT-ON-SEMAPHORE-PTR) to 1.4 branch from trunk.

See ticket:657.

Note: See TracTickets for help on using tickets.