-
Notifications
You must be signed in to change notification settings - Fork 63
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
Dropping BitmapGlyph created by Glyph::to_bitmap invalidates the Glyph and causes segfault #233
Comments
A bit unrelated, but I also noticed same issue in other methods of |
Do you have ideas of how to fix this problem? One option I can think of, is to wrap Another option is to use Line 157 in 5975d3c
|
I initially thought "Well since it seems to modify current one, copying is the best option", but then I realized that I actually misunderstood FreeType2 API. After more digging and searching, I found the "real" issue. It turns out
with this does stop segfault.
Should I open new issue for this one...? |
@YeonJi2 Yeah, that would be nice! |
Closing this one, because I think new one(#234) is the real cause of the segfault. It is basically the same thing as I mentioned above, but with a little bit more detail. |
I just created BitmapGlyph using
to_bitmap
method inGlyph
struct, and doing so caused segmentation fault.After looking at GDB backtrace, it seemed like something bad happened during one of
Drop
implementations.I did notice that
to_bitmap()
calls C functionFT_Glyph_To_Bitmap
, which modifies current glyph, but thento_bitmap
treats pointer to theself
's raw glyph as if it was newly created object. ThenBitmapGlyph
's Drop impl deallocates using its raw glyph pointer, which points to the same object asGlyph
's raw glyph, makingGlyph
's raw glyph no longer valid.Freetype-rs version
0.26.0
Code to reproduce(1)
This segfaults during drop().
Above code outputs:
And here's backtrace:
Code to reproduce(2)
Similarly, calling
to_bitmap
again also causes segfault.Output:
Backtrace:
The text was updated successfully, but these errors were encountered: