<p dir="ltr">Hi Kazu, </p>
<p dir="ltr">This sounds like something you could investigate with ghc-debug. Once the mvar blocks you can look at the stack using ghc-debug-brick which should be enlightening.<br></p>
<p dir="ltr">Matt</p>
<br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 20 Nov 2024, 01:17 Kazu Yamamoto (山本和彦) via ghc-devs, <<a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
I'm seeking of the source of the bug that my server based on Warp gets<br>
not-responding. "listThreads" shows that IOManager is blocked on a<br>
MVar permanently:<br>
<br>
2 IOManager on cap 0: ThreadBlocked BlockedOnForeignCall<br>
3 IOManager on cap 1: ThreadBlocked BlockedOnMVar<br>
4 TimerManager: ThreadBlocked BlockedOnForeignCall<br>
<br>
IOManager should have the BlockedOnForeignCall reason since it's<br>
calling epoll_wait().<br>
<br>
It's quit hard to debug this bug since I don't understand which MVar blocks<br>
IOManager of 3. Users can register MVar operations to IOManager while<br>
IOManager itself is using MVars internally.<br>
<br>
To make this kind of debugging easier, I would like ask GHC developers<br>
to extend MVar to hold its label and provide "labelMVar" like<br>
"labelThread". The same mechanism should be provided for STM as well.<br>
"BlockReason" should contain the target label.<br>
<br>
What do you think?<br>
<br>
Background: <a href="https://github.com/haskell/network/issues/590" rel="noreferrer noreferrer" target="_blank">https://github.com/haskell/network/issues/590</a><br>
<br>
--Kazu<br>
<br>
<br>
_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org" target="_blank" rel="noreferrer">ghc-devs@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
</blockquote></div>