terminate-oldest-handler sometimes causes &abandoned-mutex-exception

Issue #141 resolved
Takashi Kato repo owner created an issue

Run the following script:

(import (rnrs) (sagittarius) (sagittarius control)
        (util concurrent))

(define make-executor make-thread-pool-executor)
(define executor-pool-size thread-pool-executor-pool-size)
(define executor-max-pool-size thread-pool-executor-max-pool-size)

(dotimes (i 100)
(let ((e (make-executor 1 terminate-oldest-handler))
      (f1 (future (class <executor-future>) (thread-sleep! 10)))
      (f2 (future (class <executor-future>) (thread-sleep! 10)))
      (f3 (future (class <executor-future>) (thread-sleep! 10))))
  (print (executor? (execute-future! e f1)))
  (print (executor? (execute-future! e f2)))
  (print (future-cancelled? f1))
  (print (executor? (execute-future! e f3)))
  (print (future-cancelled? f2))
  (print (executor-pool-size e))
  (print (shutdown-executor! e))
  (print (executor-pool-size e))
  (print (future-cancelled? f3))
  )
)

And got the following (not always but very high possibility)

Unhandled exception
  Condition components:
  &abandoned-mutex-exception
    mutex: #<mutex #:mutex-1363 locked/owned by #<thread root runnable 0x20e7540>>
    thread: #<thread thread-1367 terminated 0x34b5640>
stack trace:
  [1] mutex-lock!
  [2] mutex-lock-recursively!
    src: (mutex-lock! mutex)
    "/home/takashi/sandbox/share/sagittarius/0.6.7/sitelib/util/concurrent/executor.scm":169
  [3] dynamic-wind
  [4] terminate-oldest-handler
    src: (cleanup executor (cdr oldest) 'terminated)
    "/home/takashi/sandbox/share/sagittarius/0.6.7/sitelib/util/concurrent/executor.scm":107
  [5] #f
    src: (execute-future! e f3)
  [6] load

Comments (1)

  1. Log in to comment