-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rethrow async exception #1013
Rethrow async exception #1013
Conversation
7313278
to
88b67b4
Compare
I'm a bit busy this week, but will try to take a look next week 👍 |
We now have listThreads. So, it would be nice to revisit the old idea.
|
Both |
I hope that 1400f27 fixes the leak of TimeManager. |
TimeManager is still leaking, sigh.
|
The 23 thread is gone. Why did it took so a long time? |
OK. I understand. |
TimeManager is leaking because of "BlockedOnMVar". Both TimeManger and Reaper do not use MVar at all. TLS "bye" is the only registered function which uses MVar. When TimeManager kills Warp, "bye" is called twice. One is via "bracket", the other is by TimeManager. This ensures that "bye" is called only once.
489c063
to
1400f27
Compare
I'm going to merge this PR and release new versions as this PR fixes some thread leaks. |
Few things I've found:
The difference between |
From the doc of
That is, asynchronous exceptions cannot interrupt foreign calls. |
|
|
Good point! |
How did you figure this out, btw? I can only narrow it down to an internal built-in |
See: https://www.stackage.org/haddock/lts-22.42/base-4.18.2.1/src/GHC.Conc.IO.html#threadDelay Our RTS is
threadDelay :: Int -> IO ()
threadDelay usecs = mask_ $ do
mgr <- getSystemTimerManager
m <- newEmptyMVar
reg <- TM.registerTimeout mgr usecs (putMVar m ())
takeMVar m `onException` TM.unregisterTimeout mgr reg |
@Vlix This is the first step to fix the stuffs in #1012.