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

Setting a .jpg as texture segfaults #67

Open
LilithHafner opened this issue Jan 27, 2024 · 3 comments
Open

Setting a .jpg as texture segfaults #67

LilithHafner opened this issue Jan 27, 2024 · 3 comments
Labels
Acknowledged We are aware of this issue and will respond soon C++ References the C++ Component Crash Fatal terminating Error

Comments

@LilithHafner
Copy link
Contributor

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.

@Clemapfel Clemapfel added C++ References the C++ Component Crash Fatal terminating Error Acknowledged We are aware of this issue and will respond soon labels Feb 8, 2024
@Clemapfel
Copy link
Owner

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.

@Clemapfel
Copy link
Owner

Clemapfel commented Feb 15, 2024

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.

@LilithHafner
Copy link
Contributor Author

Ah, yes. A classic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Acknowledged We are aware of this issue and will respond soon C++ References the C++ Component Crash Fatal terminating Error
Projects
None yet
Development

No branches or pull requests

2 participants