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

Core: triangle example crashes at runtime on wayland with segmentation fault. #1275

Open
nippi05 opened this issue Oct 1, 2024 · 11 comments
Labels
bug Something isn't working needs-triage Issues that need triaging

Comments

@nippi05
Copy link

nippi05 commented Oct 1, 2024

> ~/zig/0.13.0-dev.351+64ef45eb0/files/zig build run-triangle
Segmentation fault at address 0x40
???:?:?: 0x7f2b2d690700 in ??? (libwayland-client.so.0)
Unwind information for `libwayland-client.so.0:0x7f2b2d690700` was not available, trace may be incomplete

/home/nilsj/Projects/zfps/libs/mach/src/core/linux/Wayland.zig:158:76: 0x10c7e2a in init (core-triangle)
    const decoration = c.zxdg_decoration_manager_v1_get_toplevel_decoration(
                                                                           ^
/home/nilsj/Projects/zfps/libs/mach/src/core/Linux.zig:94:41: 0x10c9272 in init (core-triangle)
            const wayland = Wayland.init(linux, core, options) catch |err| switch (err) {
                                        ^
/home/nilsj/Projects/zfps/libs/mach/src/Core.zig:210:22: 0x10dd47e in init (core-triangle)
    try Platform.init(&state.platform, core, options);
                     ^
/home/nilsj/Projects/zfps/libs/mach/src/module/module.zig:444:32: 0x113ae10 in dispatchInternal__anon_13063 (core-triangle)
                .ErrorUnion => try @call(.auto, handler, args),
                               ^
/home/nilsj/Projects/zfps/libs/mach/src/module/module.zig:360:38: 0x113c74f in dispatch (core-triangle)
            return m.dispatchInternal(stack_space, options, injectable);
                                     ^
/home/nilsj/Projects/zfps/libs/mach/examples/core/triangle/main.zig:23:27: 0x113c89e in main (core-triangle)
    try mach.mods.dispatch(stack_space, .{});
                          ^
/home/nilsj/zig/0.13.0-dev.351+64ef45eb0/files/lib/std/start.zig:524:37: 0x113ccde in main (core-triangle)
            const result = root.main() catch |err| {
                                    ^
run-triangle
└─ run core-triangle failure
error: the following command terminated unexpectedly:
/home/nilsj/Projects/zfps/libs/mach/zig-out/bin/core-triangle
Build Summary: 53/55 steps succeeded; 1 failed (disable with --summary none)
run-triangle transitive failure
└─ run core-triangle failure
error: the following build command failed with exit code 1:
/home/nilsj/Projects/zfps/libs/mach/.zig-cache/o/7cfc9a16a152f450c50d3b7c363cfb8b/build /home/nilsj/zig/0.13.0-dev.351+64ef45eb0/files/zig /home/nilsj/Projects/zfps/libs/mach /home/nilsj/Projects/zfps/libs/mach/.zig-cache /home/nilsj/.cache/zig --seed 0x7c877ff2 -Z24801e53fa41fc62 run-triangle

@nippi05 nippi05 added bug Something isn't working needs-triage Issues that need triaging labels Oct 1, 2024
@RonaldZielaznicki
Copy link
Contributor

@nippi05 Would you be able to confirm that #1289 fixes this issue?

@nippi05
Copy link
Author

nippi05 commented Oct 21, 2024

@RonaldZielaznicki I'm still getting the same error 😕

@RonaldZielaznicki
Copy link
Contributor

@nippi05

Hrrrm. And just to cover the bases, this is while running the latest main? Or are you running 4.0?

@nippi05
Copy link
Author

nippi05 commented Oct 21, 2024

@RonaldZielaznicki yes master.

@dysphoriac
Copy link

dysphoriac commented Oct 22, 2024

which compositor are you using?
also try running it with WAYLAND_DEBUG=1 as an environment variable
another thing is you're running 0.13.0-dev.351+64ef45eb0, try the mach nominated zig version

@nippi05
Copy link
Author

nippi05 commented Oct 22, 2024

It's gnome so Mutter(?). I'm using mach nominated version here is output with WAYLAND_DEBUG=1:

~/Projects/zfps/libs/mach main 29s ❯ zig version           
0.14.0-dev.1911+3bf89f55c
~/Projects/zfps/libs/mach main ❯ WAYLAND_DEBUG=1 zig build run-triangle
[1642744.646]  -> [email protected]_registry(new id wl_registry@2)
[1642744.660]  -> [email protected](new id wl_callback@3)
[1642744.807] [email protected]_id(3)
[1642744.819] [email protected](1, "wl_compositor", 5)
[1642744.831]  -> [email protected](1, "wl_compositor", 3, new id [unknown]@4)
[1642744.840] [email protected](2, "wl_drm", 2)
[1642744.847] [email protected](3, "wl_shm", 1)
[1642744.856]  -> [email protected](3, "wl_shm", 1, new id [unknown]@5)
[1642744.864] [email protected](4, "wl_output", 3)
[1642744.872]  -> [email protected](4, "wl_output", 3, new id [unknown]@6)
[1642744.880] [email protected](5, "zxdg_output_manager_v1", 3)
[1642744.886] [email protected](6, "wl_data_device_manager", 3)
[1642744.893] [email protected](7, "zwp_primary_selection_device_manager_v1", 1)
[1642744.902] [email protected](8, "wl_subcompositor", 1)
[1642744.910]  -> [email protected](8, "wl_subcompositor", 1, new id [unknown]@7)
[1642744.915] [email protected](9, "xdg_wm_base", 4)
[1642744.926]  -> [email protected](9, "xdg_wm_base", 3, new id [unknown]@8)
[1642744.932] [email protected](10, "gtk_shell1", 5)
[1642744.938] [email protected](11, "wp_viewporter", 1)
[1642744.945] [email protected](12, "zwp_pointer_gestures_v1", 3)
[1642744.951] [email protected](13, "zwp_tablet_manager_v2", 1)
[1642744.956] [email protected](14, "wl_seat", 8)
[1642744.963]  -> [email protected](14, "wl_seat", 3, new id [unknown]@9)
[1642744.969] [email protected](15, "zwp_relative_pointer_manager_v1", 1)
[1642744.976] [email protected](16, "zwp_pointer_constraints_v1", 1)
[1642744.982] [email protected](17, "zxdg_exporter_v1", 1)
[1642744.988] [email protected](18, "zxdg_importer_v1", 1)
[1642744.994] [email protected](19, "zwp_linux_dmabuf_v1", 4)
[1642745.000] [email protected](20, "wp_single_pixel_buffer_manager_v1", 1)
[1642745.006] [email protected](21, "zwp_keyboard_shortcuts_inhibit_manager_v1", 1)
[1642745.013] [email protected](22, "zwp_text_input_manager_v3", 1)
[1642745.019] [email protected](23, "wp_presentation", 1)
[1642745.025] [email protected](24, "xdg_activation_v1", 1)
[1642745.031] [email protected](3082)
[1642745.038]  -> [email protected](new id wl_callback@3)
[1642745.139] [email protected]_id(3)
[1642745.151] [email protected](3)
[1642745.158]  -> [email protected]_keyboard(new id wl_keyboard@10)
[1642745.166]  -> [email protected]_pointer(new id wl_pointer@11)
[1642745.172] [email protected]("seat0")
[1642745.178] [email protected](3082)
[1642745.184]  -> [email protected]_surface(new id wl_surface@3)
[1642745.191]  -> [email protected]_region(new id wl_region@12)
[1642745.198]  -> [email protected](0, 0, 960, 540)
[1642745.204]  -> [email protected]_opaque_region(wl_region@12)
[1642745.210]  -> [email protected]()
[1642745.217]  -> [email protected]_xdg_surface(new id xdg_surface@13, wl_surface@3)
[1642745.228]  -> [email protected]_toplevel(new id xdg_toplevel@14)
[1642745.234]  -> [email protected]()
[1642747.342] [email protected]_id(12)
[1642747.359] [email protected](1, fd 4, 76270)
[1642754.533] [email protected](0, 0, array[0])
[1642754.548] [email protected](115)
[1642754.556]  -> [email protected]_configure(115)
[1642754.564]  -> [email protected]_region(new id wl_region@12)
[1642754.570]  -> [email protected](0, 0, 960, 540)
[1642754.577]  -> [email protected]_opaque_region(wl_region@12)
[1642754.582]  -> [email protected]()
[1642754.589]  -> [email protected]_title("Mach core")
Segmentation fault at address 0x40
???:?:?: 0x7ff519746700 in ??? (libwayland-client.so.0)
Unwind information for `libwayland-client.so.0:0x7ff519746700` was not available, trace may be incomplete

/home/nilsj/Projects/zfps/libs/mach/src/core/linux/Wayland.zig:158:76: 0x10f2273 in init (core-triangle)
    const decoration = c.zxdg_decoration_manager_v1_get_toplevel_decoration(
                                                                           ^
/home/nilsj/Projects/zfps/libs/mach/src/core/Linux.zig:104:41: 0x10f3f58 in init (core-triangle)
            const wayland = Wayland.init(linux, core, options) catch |err| {
                                        ^
/home/nilsj/Projects/zfps/libs/mach/src/Core.zig:210:22: 0x110833e in init (core-triangle)
    try Platform.init(&state.platform, core, options);
                     ^
/home/nilsj/Projects/zfps/libs/mach/src/module/module.zig:444:33: 0x116a112 in dispatchInternal__anon_10183 (core-triangle)
                .error_union => try @call(.auto, handler, args),
                                ^
/home/nilsj/Projects/zfps/libs/mach/src/module/module.zig:360:38: 0x116b89f in dispatch (core-triangle)
            return m.dispatchInternal(stack_space, options, injectable);
                                     ^
/home/nilsj/Projects/zfps/libs/mach/examples/core/triangle/main.zig:23:27: 0x116b9ee in main (core-triangle)
    try mach.mods.dispatch(stack_space, .{});
                          ^
/home/nilsj/zig/0.14.0-dev.1911+3bf89f55c/files/lib/std/start.zig:621:37: 0x116be2e in main (core-triangle)
            const result = root.main() catch |err| {
                                    ^
run-triangle
└─ run core-triangle failure
error: the following command terminated unexpectedly:
/home/nilsj/Projects/zfps/libs/mach/zig-out/bin/core-triangle 
Build Summary: 44/46 steps succeeded; 1 failed
run-triangle transitive failure
└─ run core-triangle failure
error: the following build command failed with exit code 1:
/home/nilsj/Projects/zfps/libs/mach/.zig-cache/o/aace89b9cb039f7ed7d7b50486356fc2/build /home/nilsj/zig/0.14.0-dev.1911+3bf89f55c/files/zig /home/nilsj/zig/0.14.0-dev.1911+3bf89f55c/files/lib /home/nilsj/Projects/zfps/libs/mach /home/nilsj/Projects/zfps/libs/mach/.zig-cache /home/nilsj/.cache/zig --seed 0x984f4825 -Zcccc9b2d2b473923 run-triangle

@dysphoriac
Copy link

it looks like its trying to set the decoration mode using the xdg-decoration protocol but that protocol is not implemented by mutter, so its just trying to access a out of bounds memory address, and it segfaults.

unfortunately unless gnome implements the protocol and provides server side decoration, which is unlikely , mach might have to provide some sort of client side decoration in order to work on fully gnome

these are basically the options:

  1. add csd to mach.

undesirable for mach devs, would probably mean adding libdecor or something like that

  1. add ssd to mutter

undesirable for gnome devs, unlikely due to philosophical differences

  1. just add something that disables the checks if the zxdg_decoration_manager_v1 exists before calling c.zxdg_decoration_manager_v1_get_toplevel_decoration()

would break window moving and resizing, kinda hacky, undesirable for everyone

@RonaldZielaznicki
Copy link
Contributor

Thank you for the insight dysphoriac. And ain't that just frustrating, looks like we're betweeen a rock and a hard place here. Checked in on the docs for the protocol, and they've a helpful graphic.

image

@slimsag Mind if I ask your opinion on what direction we'd like to go?

@slimsag
Copy link
Member

slimsag commented Oct 23, 2024

I believe that GLFW also uses libdecor by default, falling back to SSD only if libdecor is not found.

I think we should do the same here. And, obviously, we should std.DynLib the dependency on libdecor and not rely on system headers for compilation so that cross compilation works.

If libdecor is not available, we should fallback to SSD. If SSD is not available, then let's exit with an error message telling the user their OS is broken and to install libdecor - rather than e.g. having an unresizable window

@RonaldZielaznicki
Copy link
Contributor

Think as a stopgap, I'll throw up a PR that'll give a proper error if SSD is not supported.

That way we'll stop getting new/similar reports about if while libdecor is hooked up.

@slimsag
Copy link
Member

slimsag commented Oct 24, 2024

That sounds perfect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage Issues that need triaging
Projects
None yet
Development

No branches or pull requests

4 participants