From nobody@FreeBSD.ORG  Thu May 11 20:53:29 2000
Return-Path: <nobody@FreeBSD.ORG>
Received: by hub.freebsd.org (Postfix, from userid 32767)
	id C14CB37BC88; Thu, 11 May 2000 20:53:29 -0700 (PDT)
Message-Id: <20000512035329.C14CB37BC88@hub.freebsd.org>
Date: Thu, 11 May 2000 20:53:29 -0700 (PDT)
From: hwc@openfind.com.tw
Sender: nobody@FreeBSD.ORG
To: freebsd-gnats-submit@FreeBSD.org
Subject: pthread hang and Fatal error '_waitq_insert: Already in queue' at line'
X-Send-Pr-Version: www-1.0

>Number:         18510
>Category:       misc
>Synopsis:       pthread hang and Fatal error '_waitq_insert: Already in queue' at line'
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    jasone
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          doc-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu May 11 21:00:01 PDT 2000
>Closed-Date:    Tue May 23 09:45:41 PDT 2000
>Last-Modified:  Tue May 23 09:46:53 PDT 2000
>Originator:     Wei-Chen Huang
>Release:        FreeBSD 4.0 and 3.4
>Organization:
openfind (http://www.openfind.com)
>Environment:
FreeBSD sable1.iis.sinica.edu.tw 4.0-STABLE FreeBSD 4.0-STABLE #1: Fri May 12 11:19:20 CST 2000     root@sable1.iis.
sinica.edu.tw:/usr/src/sys/compile/SABLE1_MP  i386
>Description:
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..
>How-To-Repeat:

>Fix:


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->jasone 
Responsible-Changed-By: jasone 
Responsible-Changed-When: Fri May 12 00:26:04 PDT 2000 
Responsible-Changed-Why:  
Over to maintainer. 

From: "hwc" <hwc@openfind.com.tw>
To: <jasone@freebsd.org>, <freebsd-gnats-submit@freebsd.org>
Cc:  
Subject: Re: misc/18510: pthread hang and Fatal error '_waitq_insert: Already in queue' at line'
Date: Sat, 13 May 2000 19:08:25 +0800

 This is a multi-part message in MIME format.
 
 ------=_NextPart_000_001E_01BFBD0E.9D472320
 Content-Type: text/plain;
 	charset="big5"
 Content-Transfer-Encoding: quoted-printable
 
 Dear Sir:
 
 I'v  logged more information, and found ...
 
 >*26 ERR-'_waitq_insert: Already in queue',thread id=3D'134639616'
 >        thread id=3D134639616    capture SIGPIPE
 >*26 ERR-'_pq_remove: Not in priority queue',thread id=3D'134642688'
 >*26 ERR-'_waitq_insert: Already in queue',thread id=3D'134642688'
 >*26 ERR-'_pq_remove: Not in priority queue',thread id=3D'134642688'
 >*26 ERR-'_waitq_insert: Already in queue',thread id=3D'134642688'
 
 134639616 is the main thread,
 134642688 is the garbage collector thread....
 hope this informaation will be helpful..
 --
 Huang Wei-Chen
 
 
 
 
 
 ------=_NextPart_000_001E_01BFBD0E.9D472320
 Content-Type: text/html;
 	charset="big5"
 Content-Transfer-Encoding: quoted-printable
 
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 <HTML><HEAD>
 <META content=3D"text/html; charset=3Dbig5" http-equiv=3DContent-Type>
 <META content=3D"MSHTML 5.00.2920.0" name=3DGENERATOR>
 <STYLE></STYLE>
 </HEAD>
 <BODY bgColor=3D#ffffff>
 <DIV><FONT face=3DArial size=3D2>Dear Sir:</FONT></DIV>
 <DIV>&nbsp;</DIV>
 <DIV><FONT face=3DArial size=3D2>I'v&nbsp; logged more information, and =
 found=20
 ...</FONT></DIV>
 <DIV>&nbsp;</DIV>
 <DIV><FONT face=3DArial size=3D2>&gt;*26 ERR-'_waitq_insert: Already in=20
 queue',thread =
 id=3D'134639616'<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
 thread id=3D134639616&nbsp;&nbsp;&nbsp; capture SIGPIPE<BR>&gt;*26=20
 ERR-'_pq_remove: Not in priority queue',thread =
 id=3D'134642688'<BR>&gt;*26=20
 ERR-'_waitq_insert: Already in queue',thread id=3D'134642688'<BR>&gt;*26 =
 
 ERR-'_pq_remove: Not in priority queue',thread =
 id=3D'134642688'<BR>&gt;*26=20
 ERR-'_waitq_insert: Already in queue',thread =
 id=3D'134642688'<BR></FONT></DIV>
 <DIV><FONT face=3DArial size=3D2>134639616 is the main =
 thread,</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2>134642688 is the garbage collector=20
 thread....</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2>hope this informaation will be=20
 helpful..</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2>--</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2>Huang Wei-Chen</FONT></DIV>
 <DIV>&nbsp;</DIV>
 <DIV>&nbsp;</DIV>
 <DIV><FONT face=3DArial size=3D2><BR>&nbsp;</DIV></FONT></BODY></HTML>
 
 ------=_NextPart_000_001E_01BFBD0E.9D472320--
 
 

From: "Wei-Chen Huang" <hwc@openfind.com.tw>
To: <freebsd-gnats-submit@freebsd.org>, <hwc@openfind.com.tw>
Cc:  
Subject: Re: misc/18510: pthread hang and Fatal error '_waitq_insert: Already in queue' at line'
Date: Tue, 23 May 2000 17:32:20 +0800

 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
 
 
 
State-Changed-From-To: open->closed 
State-Changed-By: jasone 
State-Changed-When: Tue May 23 09:45:41 PDT 2000 
State-Changed-Why:  
The PR originator determined the problem to be an application programming error. 
>Unformatted:
