Clemapfel / Mousetrap.jl

Finally, a GUI Engine made for Julia

Home Page:https://clemens-cords.com/mousetrap

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Setting a .jpg as texture segfaults

LilithHafner opened this issue · comments

This code produces a segfault:

using Mousetrap
main() do app::Application

    window = Window(app)
    set_title!(window, "Issue 67")
    render_area = RenderArea()
    shape = Rectangle(Vector2f(-1, 1), Vector2f(2, 2))

    image = Image("path/to/example.jpg")
    # image = Image("path/to/example.png")

    texture = Texture()
    create_from_image!(texture, image)

    set_texture!(shape, texture)

    add_render_task!(render_area, RenderTask(shape))

    set_size_request!(render_area, Vector2f(500, 500))
    set_child!(window, render_area)
    present!(window)
end

Result:

[216028] signal (11.2): Segmentation fault
in expression starting at /home/x/.julia/dev/battlecode/render_cube.jl:8
__GI_memcpy at /lib64/libc.so.6 (unknown line)
unknown function (ip: 0xffff71482167)
Allocations: 2035102 (Pool: 2033442; Big: 1660); GC: 3
Segmentation fault (core dumped)

Using a .png works around the issue.

I can reproduce this, it's a bug in the C++ component. It may take some time to update, as any changes need to be merged with the binary builder build tree. This is a pretty big issue though, thank you for pointing it out.

Fixed by Clemapfel/mousetrap@d12ae02, it will take some time to go live since it needs to be reviewed by the binary builder people and uploaded to the registry.

If you're curious, it was because some jpg files do not have an alpha channel, but the texture loading assumed it did, so it went too far into memory and segfaulted when loading the image data.

Ah, yes. A classic.