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

encodeUtf and decodeUtf incorrectly catch asynchronous exceptions #22

Open
wz1000 opened this issue Nov 14, 2024 · 2 comments · May be fixed by #24
Open

encodeUtf and decodeUtf incorrectly catch asynchronous exceptions #22

wz1000 opened this issue Nov 14, 2024 · 2 comments · May be fixed by #24

Comments

@wz1000
Copy link
Contributor

wz1000 commented Nov 14, 2024

encodeWith and decodeWith use try @SomeException to catch all exceptions that may arise while dealing with C buffers.

See for instance

r <- try @SomeException $ GHC.withCStringLen enc str $ \cstr -> WindowsString <$> BS8.packCStringLen cstr

This is incorrect, as asynchronous exceptions thrown to such code (for instance using killThread or ^C) should not result in a EncodingException.

The simplest way to fix it is to see if the exception is SomeAsyncException and if so reraise it.

See also https://gitlab.haskell.org/ghc/ghc/-/issues/25479

@hasufell
Copy link
Member

Can you provide a PR?

hasufell added a commit that referenced this issue Nov 15, 2024
@hasufell hasufell linked a pull request Nov 15, 2024 that will close this issue
hasufell added a commit to haskell/filepath that referenced this issue Nov 15, 2024
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 a pull request may close this issue.

2 participants