From owner-freebsd-threads@freebsd.org Sat Aug 20 20:52:57 2016 Return-Path: Delivered-To: freebsd-threads@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 18F45BC017F for ; Sat, 20 Aug 2016 20:52:57 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F320C15B1 for ; Sat, 20 Aug 2016 20:52:56 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id u7KKqusP036408 for ; Sat, 20 Aug 2016 20:52:56 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-threads@FreeBSD.org Subject: [Bug 211947] bconsole won't die sitting on do_rw_wrlock Date: Sat, 20 Aug 2016 20:52:57 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: threads X-Bugzilla-Version: 10.3-STABLE X-Bugzilla-Keywords: regression X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: longwitz@incore.de X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-threads@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Aug 2016 20:52:57 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D211947 longwitz@incore.de changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |longwitz@incore.de --- Comment #1 from longwitz@incore.de --- I need help with this problem and give some more infos: bconsole creates two threads: watchdog and checker_deadlock. When trying to quit bconsole the main thread sends first a special ping to the watchdog th= read and this thread always stops cleanly without any problems. Second the main thread tries to stop the sleeping thread checker_deadlock with pthread_cancel(). Both the main thread and the checker_deadlock thread do s= ome housekeeping in exit routines. I give ktraces of good and bad case starting with pthread_cancel: good (quit exits normally): 54503 100490 bconsole CALL thr_kill(0x18b71,SIG 32) 54503 100490 bconsole RET thr_kill 0 54503 101233 bconsole RET nanosleep -1 errno 4 Interrupted system call 54503 101233 bconsole PSIG SIG 32 caught handler=3D0x80205b080 mask=3D0x0 code=3DSI_LWP 54503 100490 bconsole CALL _umtx_op(0x802270880,UMTX_OP_RW_WRLOCK,0,0,0) 54503 101233 bconsole CALL thr_wake(0x18b71) 54503 100490 bconsole RET _umtx_op 0 54503 101233 bconsole RET thr_wake 0 54503 101233 bconsole CALL thr_wake(0x18b71) 54503 101233 bconsole RET thr_wake 0 54503 101233 bconsole CALL sigreturn(0x7fffdfffda60) 54503 101233 bconsole RET sigreturn JUSTRETURN 54503 100490 bconsole CALL _umtx_op(0x802270880,UMTX_OP_RW_WRLOCK,0,0,0) 54503 100490 bconsole RET _umtx_op 0 54503 101233 bconsole CALL _umtx_op(0x802270880,UMTX_OP_RW_RDLOCK,0,0,0) 54503 101233 bconsole RET _umtx_op 0 54503 100490 bconsole CALL _umtx_op(0x802270880,UMTX_OP_RW_WRLOCK,0,0,0) 54503 100490 bconsole RET _umtx_op 0 54503 101233 bconsole CALL _umtx_op(0x802270880,UMTX_OP_RW_RDLOCK,0,0,0) 54503 101233 bconsole RET _umtx_op 0 54503 100490 bconsole CALL _umtx_op(0x802270880,UMTX_OP_RW_WRLOCK,0,0,0) 54503 101233 bconsole CALL _umtx_op(0x802270880,UMTX_OP_RW_UNLOCK,0,0,0) 54503 101233 bconsole RET _umtx_op 0 54503 100490 bconsole RET _umtx_op 0 54503 101233 bconsole CALL _umtx_op(0x802270880,UMTX_OP_RW_RDLOCK,0,0,0) 54503 101233 bconsole RET _umtx_op 0 54503 101233 bconsole CALL munmap(0x800663000,0x1000) 54503 101233 bconsole RET munmap 0 54503 101233 bconsole CALL madvise(0x803806000,0x8000,MADV_FREE) 54503 101233 bconsole RET madvise 0 54503 100490 bconsole CALL exit(0) 54503 101233 bconsole CALL thr_exit(0x803406800)=20 bad (hang on quit): 62196 100096 bconsole 0.655701 CALL thr_kill(0x186f8,SIG 32) 62196 100096 bconsole 0.655717 RET thr_kill 0 62196 100088 bconsole 0.655726 RET nanosleep -1 errno 4 Interrupted syst= em call 62196 100088 bconsole 0.655742 PSIG SIG 32 caught handler=3D0x80205b080 mask=3D0x0 code=3DSI_LWP 62196 100096 bconsole 0.655766 CALL=20 _umtx_op(0x802270880,UMTX_OP_RW_WRLOCK,0,0,0) 62196 100088 bconsole 0.655770 CALL thr_wake(0x186f8) 62196 100096 bconsole 0.655774 RET _umtx_op 0 62196 100088 bconsole 0.655781 RET thr_wake 0 62196 100088 bconsole 0.655791 CALL thr_wake(0x186f8) 62196 100088 bconsole 0.655795 RET thr_wake 0 62196 100088 bconsole 0.655800 CALL sigreturn(0x7fffdfffda60) 62196 100088 bconsole 0.655807 RET sigreturn JUSTRETURN 62196 100096 bconsole 0.655830 CALL=20 _umtx_op(0x802270880,UMTX_OP_RW_WRLOCK,0,0,0) 62196 100096 bconsole 0.655837 RET _umtx_op 0 62196 100088 bconsole 0.655838 CALL=20 _umtx_op(0x802270880,UMTX_OP_RW_RDLOCK,0,0,0) 62196 100088 bconsole 0.655848 RET _umtx_op 0 62196 100096 bconsole 0.655848 CALL=20 _umtx_op(0x802270880,UMTX_OP_RW_WRLOCK,0,0,0) 62196 100088 bconsole 0.655862 CALL=20 _umtx_op(0x802270880,UMTX_OP_RW_UNLOCK,0,0,0) 62196 100088 bconsole 0.655875 RET _umtx_op 0 62196 100088 bconsole 0.655885 CALL=20 _umtx_op(0x802270880,UMTX_OP_RW_RDLOCK,0,0,0) 62196 100096 bconsole 0.655885 RET _umtx_op 0 62196 100088 bconsole 0.655897 RET _umtx_op -1 errno 4 Interrupted system call 62196 100096 bconsole 0.655901 CALL=20 _umtx_op(0x802270880,UMTX_OP_RW_UNLOCK,0,0,0) 62196 100088 bconsole 0.655903 CALL=20 _umtx_op(0x802270880,UMTX_OP_RW_RDLOCK,0,0,0) 62196 100096 bconsole 0.655912 RET _umtx_op 0 62196 100088 bconsole 0.655915 RET _umtx_op 0 62196 100096 bconsole 0.655930 CALL=20 _umtx_op(0x802270880,UMTX_OP_RW_WRLOCK,0,0,0) 62196 100088 bconsole 0.655930 CALL=20 _umtx_op(0x802270880,UMTX_OP_RW_UNLOCK,0,0,0) 62196 100088 bconsole 0.655942 RET _umtx_op 0 62196 100088 bconsole 0.655952 CALL=20 _umtx_op(0x802270880,UMTX_OP_RW_UNLOCK,0,0,0) 62196 100088 bconsole 0.655956 RET _umtx_op 0 62196 100088 bconsole 0.655966 CALL=20 _umtx_op(0x802270880,UMTX_OP_RW_UNLOCK,0,0,0) 62196 100088 bconsole 0.655971 RET _umtx_op 0 62196 100088 bconsole 0.655978 CALL=20 _umtx_op(0x802270880,UMTX_OP_RW_UNLOCK,0,0,0) 62196 100088 bconsole 0.655982 RET _umtx_op 0 62196 100088 bconsole 0.655989 CALL=20 _umtx_op(0x802270880,UMTX_OP_RW_UNLOCK,0,0,0) 62196 100088 bconsole 0.655993 RET _umtx_op 0 62196 100088 bconsole 0.655999 CALL=20 _umtx_op(0x802270880,UMTX_OP_RW_UNLOCK,0,0,0) 62196 100088 bconsole 0.656005 RET _umtx_op 0 62196 100088 bconsole 0.656010 CALL80,UMTX_OP_RW_UNLOCK,0,0,0) 62196 100088 bconsole 0.656014 RET _umtx_op 0 62196 100088 bconsole 0.656022 CALL=20 _umtx_op(0x802270880,UMTX_OP_RW_UNLOCK,0,0,0) 62196 100088 bconsole 0.656026 RET _umtx_op 0 62196 100088 bconsole 0.656032 CALL munmap(0x800663000,0x1000) 62196 100088 bconsole 0.656042 RET munmap 0 62196 100088 bconsole 0.656089 CALL madvise(0x803806000,0x8000,MADV_FREE) 62196 100088 bconsole 0.656099 RET madvise 0 62196 100088 bconsole 0.656105 CALL thr_exit(0x803406800) and the main thread does not die, he sits on WCHAN uwrlck. Especially I lik= e to know, why the kernel sends a second signal to the checker_deadlock thread. I can avoid the libthr/kernel problem by sleeping some ms in the main thread after pthread_cancel(), the resulting ktrace looks like rather clean, becau= se no _umtx_op calls to the kernel are necessary: 81803 100271 bconsole 8.425361 CALL thr_kill(0x18a20,SIG 32) 81803 100271 bconsole 8.425374 RET thr_kill 0 81803 100271 bconsole 8.425380 CALL nanosleep(0x7fffffffe2f0,0) 81803 100896 bconsole 8.425382 RET nanosleep -1 errno 4 Interrupted syst= em call 81803 100896 bconsole 8.425400 PSIG SIG 32 caught handler=3D0x80205b080 mask=3D0x0 code=3DSI_LWP 81803 100896 bconsole 8.425426 CALL thr_wake(0x18a20) 81803 100896 bconsole 8.425433 RET thr_wake 0 81803 100896 bconsole 8.425438 CALL thr_wake(0x18a20) 81803 100896 bconsole 8.425442 RET thr_wake 0 81803 100896 bconsole 8.425446 CALL sigreturn(0x7fffdfffda60) 81803 100896 bconsole 8.425452 RET sigreturn JUSTRETURN 81803 100896 bconsole 8.425519 CALL munmap(0x800663000,0x1000) 81803 100896 bconsole 8.425529 RET munmap 0 81803 100896 bconsole 8.425575 CALL madvise(0x80380e000,0x22000,MADV_FREE) 81803 100896 bconsole 8.425585 RET madvise 0 81803 100896 bconsole 8.425595 CALL madvise(0x803806000,0x8000,MADV_FREE) 81803 100896 bconsole 8.425603 RET madvise 0 81803 100896 bconsole 8.425609 CALL thr_exit(0x803406800) 81803 100271 bconsole 8.427522 RET nanosleep 0 81803 100271 bconsole 8.427717 CALL exit(0) In my opinion this problem must be solved in libthr/kernel and not in userl= and. --=20 You are receiving this mail because: You are the assignee for the bug.=