Skip to content

encodeUtf and decodeUtf incorrectly catch asynchronous exceptions #22

Closed
@wz1000

Description

@wz1000

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions