[Bug 254995] pthread_cond_timedwait() returns EDEADLK

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Mon Apr 19 07:24:39 UTC 2021


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=254995

--- Comment #2 from nkoch at demig.de ---
Yes, that is the thread that dead locks.

I do not stop the process (to my knowledge).

I am having a simple producer-consumer queue with 2 conds not_empty and
not_full and one mutex (process local, PTHREAD_MUTEX_ERRORCHECK,
PTHREAD_PRIO_INHERIT).
EDEADLK comes from the consumer waiting for anything with timeout.
The timeout is 100ms only as there is a regular keep alive check of
this thread.
The producer never waits.

So its basically this:

consumer thread:
  for(;;) {
    pthread_mutex_lock()
    if queue_empty()
      phtread_cond_timedwait() // <-- EDEADLK once in a month
    if !queue_empty() {
      read from queue
      pthread_cond_signal(not_full)
    }
    pthread_mutex_unlock()
    signal_alive()
    do_something()
  }


producer thread:
  ...
  pthread_mutex_lock()
  if !queue_full() {
    write to queue
    pthread_cond_signal(not_empty)
  }
  pthread_mutex_unlock()
  ...


BTW, there are about 32 threads with different realtime priorities and the
programs very often forks/execs other programs.

I have never seen this under FreeBSD 10.3 and 9.1 with the same software, but
that may of course mean that there were other effects I did not see so far.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-threads mailing list