Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 20 Aug 2016 20:52:57 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-threads@FreeBSD.org
Subject:   [Bug 211947] bconsole won't die sitting on do_rw_wrlock
Message-ID:  <bug-211947-16-1MkbM2fQ1b@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-211947-16@https.bugs.freebsd.org/bugzilla/>
References:  <bug-211947-16@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
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.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-211947-16-1MkbM2fQ1b>