-
Notifications
You must be signed in to change notification settings - Fork 52
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
Weird panic inside the xi-unicode crate, perhaps relating to UTF-8 encoding #124
Comments
I think the first step is to find the inputs to glyph_brush that produce a
panic, that should be easier than going direct to xi-unicode.
From that we can figure out the underlying issues, wherever they are.
Can you dbg! your glyph_brush calls that panic?
On the other hand if it isn't behaving deterministically this could be a
pain.
|
Thanks for encouraging me to dig further. I managed to replicate the problem and found an issue with my code that I have now fixed. Here's a quick explanation if you're curious. Basically, it was a use-after-free bug and glyph-brush was pointing to invalid memory - hence the garbled UTF-8 and crashes. The lifetimes in my game are a bit tricky. I store strings against game entities but also store an index of glyph-brush To workaround this, I intentionally leak the strings so that they become static and can be happily referenced by Serves me right for using unsafe code! I'll close this now as it's resolved. Thanks! |
Wow that's wild, thanks for getting to the bottom of this & explaining! There are |
Thanks, I'll check those out! They might be just what I need. 👍 |
Hello, I'm using glyph-brush to render text to a framebuffer for a game that I'm making.
Occasionally, the game is crashing due to a panic deep inside the xi-unicode crate which glyph-brush is using.
Backtrace:
I have tried to investigate by adding some extra logging around this line in xi-unicode:
Before:
After:
I then ran the game again until another panic occurred and it logged the following:
I then tried to build a
str
from these bytes in Rust and received the following error:It seems like these bytes are an invalid UTF-8 sequence. I tried putting them into this converter tool and it says "Error: Invalid UTF-8 detected". I tried removing all bytes except the first four and it successfully decodes as
"E
. I'm not sure what this string is supposed to say.As far as I'm aware, my game isn't using any weird characters so I'm not really sure what's going on. I haven't yet been able to make it crash predictably every time. I don't think the panic is specific to any one text string but it's hard to say. It seems like glyph-brush might passing invalid UTF-8 to the xi-unicode crate.
I thought I'd ask here if you have any idea what's going and whether there's a bug in my code, glyph-brush or the xi-unicode crate? I can open an issue there as well but thought I'd ask here first.
Many thanks!
The text was updated successfully, but these errors were encountered: