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

UserBinaryMessage containing non utf8 text leads to runtime error #90

Closed
TeofilC opened this issue Aug 1, 2022 · 1 comment · Fixed by #91
Closed

UserBinaryMessage containing non utf8 text leads to runtime error #90

TeofilC opened this issue Aug 1, 2022 · 1 comment · Fixed by #91

Comments

@TeofilC
Copy link
Contributor

TeofilC commented Aug 1, 2022

The logic for printing UserBinaryMessages assumes that the payload is utf8 encoded. Non-utf8 encoded payloads, like those produced by programs that use the opentelemetry library, will lead to a runtime error.

You can reproduce this by running the following to produce an eventlog:

module Main where

import Debug.Trace.Binary
import Data.ByteString

main :: IO ()
main = traceBinaryEventIO (pack [0x0080])

and then when you load this into ghc-events you will get output like the following:

> ghc-events inc repro.eventlog 
93401: cap 0: creating thread 1
94801: cap 0: running thread 1
102801: cap 0: stopping thread 1 (making a foreign call)
103101: cap 0: running thread 1
ghc-events: user error (Cannot decode byte '\x80': Data.Text.Internal.Encoding.decodeUtf8: Invalid UTF-8 stream)

Threadscope will also crash when showing relevant events.

I'll try to fix this. I feel like if we fail to decode as utf8 then we should have some sort of fallback format like base64 rather than throwing an error. Or perhaps we can just use decodeUtf8Lenient

@Mikolaj
Copy link
Member

Mikolaj commented Aug 2, 2022

That sounds very reasonable (both ways).

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