Skip to content
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

Don't leak exceptions from managed threads #92

Merged

Conversation

edsko
Copy link
Collaborator

@edsko edsko commented Sep 28, 2023

This PR makes a subtle but useful change to forkManaged[Unmask]: instead of using onException (which is what bracket does), we use catch: onException will rethrow the exception, but this is not very useful: the only exception handler that sits above the thread is the one installed by default by forkIOWithUnmask, which just prints the exception to the terminal. As a result, when the thread manager shuts down managed threads, sometimes those KilledByHttp2ThreadManager exceptions were printed to the terminal, interfering with the regular output of the program. (Specifically, I was observing this with the thread spawned by forkAndEnqueueWhenReady in Arch/Sender.hs.)

Copy link
Collaborator Author

@edsko edsko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I made a mistake. This is deleting the thread ID twice. Shouldn't matter ,but will fix anyway.

@edsko
Copy link
Collaborator Author

edsko commented Sep 28, 2023

Fixed.

Copy link
Owner

@kazu-yamamoto kazu-yamamoto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. This is a nice improvement.

@kazu-yamamoto kazu-yamamoto merged commit c2a2994 into kazu-yamamoto:master Sep 28, 2023
10 checks passed
@kazu-yamamoto
Copy link
Owner

Merged.
Thanks!

@edsko edsko deleted the edsko/dont-leak-exceptions branch September 29, 2023 07:04
edsko added a commit to edsko/http2 that referenced this pull request Jul 19, 2024
In kazu-yamamoto#92 we added an exception handler
that was meant to catch _all_ exceptions (sync and async). This got changed in
kazu-yamamoto#114 (specifically,
kazu-yamamoto@52a9619):
when we moved from `Control.Exception` to `UnliftIO.Exception`, we got a
different behaviour for `catch` and friends (see
well-typed/grapesy#193 (comment)) for a
full list. This commit fixes some unintended consequences of this change.
edsko added a commit to edsko/http2 that referenced this pull request Jul 23, 2024
In kazu-yamamoto#92 we added an exception handler
that was meant to catch _all_ exceptions (sync and async). This got changed in
kazu-yamamoto#114 (specifically,
kazu-yamamoto@52a9619):
when we moved from `Control.Exception` to `UnliftIO.Exception`, we got a
different behaviour for `catch` and friends (see
well-typed/grapesy#193 (comment)) for a
full list. This commit fixes some unintended consequences of this change.
edsko added a commit to edsko/http2 that referenced this pull request Jul 24, 2024
In kazu-yamamoto#92 we added an exception handler
that was meant to catch _all_ exceptions (sync and async). This got changed in
kazu-yamamoto#114 (specifically,
kazu-yamamoto@52a9619):
when we moved from `Control.Exception` to `UnliftIO.Exception`, we got a
different behaviour for `catch` and friends (see
well-typed/grapesy#193 (comment)) for a
full list. This commit fixes some unintended consequences of this change.
edsko added a commit to edsko/http2 that referenced this pull request Jul 24, 2024
In kazu-yamamoto#92 we added an exception handler
that was meant to catch _all_ exceptions (sync and async). This got changed in
kazu-yamamoto#114 (specifically,
kazu-yamamoto@52a9619):
when we moved from `Control.Exception` to `UnliftIO.Exception`, we got a
different behaviour for `catch` and friends (see
well-typed/grapesy#193 (comment)) for a
full list. This commit fixes some unintended consequences of this change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants