[haiku-bugs] Re: [Haiku] #11482: pthreads: possible race condition leading to deadlock

  • From: "hamish" <trac@xxxxxxxxxxxx>
  • Date: Tue, 05 May 2015 00:21:22 -0000

#11482: pthreads: possible race condition leading to deadlock
---------------------------------+----------------------------
Reporter: jessicah | Owner: axeld
Type: bug | Status: new
Priority: normal | Milestone: R1
Component: System/libroot.so | Version: R1/Development
Resolution: | Keywords:
Blocked By: | Blocking:
Has a Patch: 1 | Platform: All
---------------------------------+----------------------------

Comment (by hamish):

This seems to be a missed wake-up problem. In the current `user_mutex`
implementation, the waking thread wakes the waiting one, but leaves it on
the queue. The woken-up thread eventually runs and dequeues itself. For
condition variables, this means multiple signals can just keep on waking
up the same thread, until that thread eventually runs and dequeues itself.

Attached is a patch to address the issue (dequeue at the waker side
instead; a waiter only dequeues itself if it was interrupted or timed
out). Fixes the Boost condvar tests, and the POSIX test suite tests still
pass. I would appreciate if someone else could take a look and tell me if
I'm doing something wrong here though :)

--
Ticket URL: <https://dev.haiku-os.org/ticket/11482#comment:5>
Haiku <https://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: