Bug with fcntl locks, pthread mutexes, and threads?

Manoj Kasichainula (manojk@raleigh.ibm.com)
Tue, 27 Apr 1999 19:14:28 -0400


I think I'm running into a very complicated threading bug.

To reproduce it, I use the attached C program. The program forks off
two child processes, each with two threads. Each thread tries to grab
a two-layer lock, with a pthread lock followed by an fcntl lock. The
thread then sleeps for a long time. So, once we have a thread that has
gotten through both locks, we have:

process 1:
thread 1: holds pthread lock, holds fcntl lock, sleeping
thread 2: waiting on pthread lock
process 2:
thread 1: holds pthread lock, waiting on fcntl lock
thread 2: waiting on pthread lock

Then I kill -TERM process 1. All of its threads go away, but process
2, thread 1 never wakes up out of fcntl(). lsof claims that none of
the remaining processes/threads hold the lock.

This sounds like a bug.

-- 
Manoj Kasichainula - manojk@raleigh.ibm.com
IBM, Apache Development

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/