Subject: lib/25722: pthread assertion failure in deadlock situation
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <kent@NetBSD.org>
List: netbsd-bugs
Date: 05/27/2004 07:14:07
>Number: 25722
>Category: lib
>Synopsis: pthread assertion failure in deadlock situation
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: lib-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu May 27 07:15:01 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator: TAMURA Kent
>Release: NetBSD-current (2.0F)
>Organization:
NetBSD
>Environment:
>Description:
libpthread throws assertion failure when a thread deadlocks by
pthread_mutex_lock() and there are no other threads.
>How-To-Repeat:
--------- mutex.c
#include <pthread.h>
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
int main() {
printf("lock 1\n");
pthread_mutex_lock(&mutex);
printf("lock 2\n");
pthread_mutex_lock(&mutex);
printf("exit\n");
return 0;
}
--------
% cc -o mutex mutex.c -lpthread
% ./mutex
lock 1
lock 2
assertion "next != 0" failed: file "/usr/src/lib/libpthread/pthread_run.c", line 130, function "pthread__next"
zsh: abort (core dumped) ./mutex
backtrace is:
#0 0x4808c26b in kill () from /usr/lib/libc.so.12
#1 0x4806b772 in pthread__assertfunc () from /usr/lib/libpthread.so.0
#2 0x48067e4c in pthread__next () from /usr/lib/libpthread.so.0
#3 0x48067cf5 in pthread__block () from /usr/lib/libpthread.so.0
#4 0x480688d6 in pthread_mutex_lock () from /usr/lib/libpthread.so.0
#5 0x48068797 in pthread_mutex_lock () from /usr/lib/libpthread.so.0
#6 0x08048859 in main ()
#7 0x080485b2 in ___start ()
Note that mutex.c is wrong code definitely. But, according to SUS v3,
the code should cause deadlock at the second pthread_mutex_lock(), and
assertion failure should not occur anyway.
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: