Bug 18510

Summary: pthread hang and Fatal error '_waitq_insert: Already in queue' at line'
Product: Base System Reporter: hwc <hwc>
Component: miscAssignee: Jason Evans <jasone>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description hwc 2000-05-12 05:00:01 UTC
I'm programing a http proxy using pthread ..
Sometimes program will hang and cpu is 9x%....

I rebuild libc_r with -D_PTHREADS_INVARIANTS -g
then, got 
Fatal error '_pq_remove: Not in priority queue' at line ? in file /usr/src/lib/libc_r/uthread/uthread_priority_queue.c (errno = ?)
program terminated....

I'v modified some code, to log thread_id, capture signal and let the program continue...

Then
*26 ERR-'_waitq_insert: Already in queue',thread id='134639616'
        thread id=134639616    capture SIGPIPE
*26 ERR-'_pq_remove: Not in priority queue',thread id='134642688'
*26 ERR-'_waitq_insert: Already in queue',thread id='134642688'
*26 ERR-'_pq_remove: Not in priority queue',thread id='134642688'
*26 ERR-'_waitq_insert: Already in queue',thread id='134642688'
*26 ERR-'_pq_remove: Not in priority queue',thread id='134642688'
*26 ERR-'_waitq_insert: Already in queue',thread id='134642688'
*26 ERR-'_pq_remove: Not in priority queue',thread id='134642688'
*26 ERR-'_waitq_insert: Already in queue',thread id='134642688'
infinite loop


This condition happened in FreeBSD 3.4, and FreeBSD 4.0,
I'v updated source code (cvsup) and make world..
Comment 1 Jason Evans freebsd_committer freebsd_triage 2000-05-12 08:26:04 UTC
Responsible Changed
From-To: freebsd-bugs->jasone

Over to maintainer. 

Comment 2 hwc 2000-05-13 12:08:25 UTC
Dear Sir:

I'v  logged more information, and found ...

>*26 ERR-'_waitq_insert: Already in queue',thread id='134639616'
>        thread id=134639616    capture SIGPIPE
>*26 ERR-'_pq_remove: Not in priority queue',thread id='134642688'
>*26 ERR-'_waitq_insert: Already in queue',thread id='134642688'
>*26 ERR-'_pq_remove: Not in priority queue',thread id='134642688'
>*26 ERR-'_waitq_insert: Already in queue',thread id='134642688'


134639616 is the main thread,
134642688 is the garbage collector thread....
hope this informaation will be helpful..
--
Huang Wei-Chen



Comment 3 hwc 2000-05-23 10:32:20 UTC
Sorry... It seems my fault!!!

I'v used pthread_mutex_lock when dumping message in signal handling
function,
and it is undefined to call these pthread functions in signal handler ....

Sorry.. to waste your time.. again.
--
Huang Wei-Chen
Comment 4 Jason Evans freebsd_committer freebsd_triage 2000-05-23 17:45:41 UTC
State Changed
From-To: open->closed

The PR originator determined the problem to be an application programming error.