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

Enabling zwp_idle_inhibit_manager_v1 causes Mir to crash with some applications #2836

Closed
OPNA2608 opened this issue Feb 14, 2023 · 6 comments · Fixed by #2842
Closed

Enabling zwp_idle_inhibit_manager_v1 causes Mir to crash with some applications #2836

OPNA2608 opened this issue Feb 14, 2023 · 6 comments · Fixed by #2842
Assignees
Labels

Comments

@OPNA2608
Copy link
Contributor

(The latest releases of) Taisei & Teeworlds as well as some other closed-source applications that can spawn Wayland windows via SDL2 cause the following error in the logs when their window is closed.

[2023-02-13 15:05:53.822899] < -warning- > frontend:Wayland: Exception processing WlSurface::~WlSurface() request: /build/source/src/server/frontend_wayland/window_wl_surface_role.cpp(416): Throw in function surface_destroyed
Dynamic exception type: boost::wrapexcept<std::runtime_error>
std::exception::what: wl_surface@28 destroyed before associated role

error in client communication (pid 204373)

If

  • there is no current X11/Wayland session (i.e. runlevel 3),
  • a new Mir session is started (on a tty or via ssh) with the zwp_idle_inhibit_manager_v1 Wayland extension enabled, and
  • within this session, one such application causes this error

then this instead crashes the entire Mir session. I've verified this behaviour on NixOS unstable (miral-app & Miriway) and Ubuntu 22.10 (ubuntu-frame snap & source-built miral-app), Mir 2.12.0 and current master (a35b397).

!!! Fatal signal received. Attempting cleanup, but deadlock may occur
Mir fatal error: Unsupported attempt to continue after a fatal signal: SIGSEGV
!!! Fatal signal received. Attempting cleanup, but deadlock may occur
Mir fatal error: Unsupported attempt to continue after a fatal signal: SIGABRT

Here is the gdb backtrace with debug information.

Thread 16 "Mir/Wayland" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fd37ee840 (LWP 435461)]
0x0000007ff6bdd5a0 in wl_closure_invoke (closure=closure@entry=0x7fc0052830, flags=flags@entry=2, target=<optimized out>, opcode=0, data=<optimized out>, data@entry=0x7fc0000fb0) at ../src/connection.c:1021
1021	../src/connection.c: No such file or directory.
(gdb) bt
#0  0x0000007ff6bdd5a0 in wl_closure_invoke (closure=closure@entry=0x7fc0052830, flags=flags@entry=2, target=<optimized out>, opcode=0, data=<optimized out>, data@entry=0x7fc0000fb0) at ../src/connection.c:1021
#1  0x0000007ff6bd97d0 in wl_client_connection_data (fd=<optimized out>, mask=<optimized out>, data=0x7fc0000fb0) at ../src/wayland-server.c:437
#2  0x0000007ff6bdb678 in wl_event_loop_dispatch (loop=0xe2e750, timeout=timeout@entry=-1) at ../src/event-loop.c:1027
#3  0x0000007ff6bd9a44 in wl_display_run (display=display@entry=0xe2e660) at ../src/wayland-server.c:1431
#4  0x0000007ff7736450 in <lambda(wl_display*)>::operator() (__closure=<optimized out>, d=0xe2e660) at /build/source/src/server/frontend_wayland/wayland_connector.cpp:394
#5  std::__invoke_impl<void, mir::frontend::WaylandConnector::start()::<lambda(wl_display*)>, wl_display*> (__f=...) at /nix/store/4mhhaggjp57h7sr8diiiskbb86nh4ppy-gcc-9.5.0/include/c++/9.5.0/bits/invoke.h:60
#6  std::__invoke<mir::frontend::WaylandConnector::start()::<lambda(wl_display*)>, wl_display*> (__fn=...) at /nix/store/4mhhaggjp57h7sr8diiiskbb86nh4ppy-gcc-9.5.0/include/c++/9.5.0/bits/invoke.h:95
#7  std::thread::_Invoker<std::tuple<mir::frontend::WaylandConnector::start()::<lambda(wl_display*)>, wl_display*> >::_M_invoke<0, 1> (this=<optimized out>) at /nix/store/4mhhaggjp57h7sr8diiiskbb86nh4ppy-gcc-9.5.0/include/c++/9.5.0/thread:244
#8  std::thread::_Invoker<std::tuple<mir::frontend::WaylandConnector::start()::<lambda(wl_display*)>, wl_display*> >::operator() (this=<optimized out>) at /nix/store/4mhhaggjp57h7sr8diiiskbb86nh4ppy-gcc-9.5.0/include/c++/9.5.0/thread:251
#9  std::thread::_State_impl<std::thread::_Invoker<std::tuple<mir::frontend::WaylandConnector::start()::<lambda(wl_display*)>, wl_display*> > >::_M_run(void) (this=<optimized out>) at /nix/store/4mhhaggjp57h7sr8diiiskbb86nh4ppy-gcc-9.5.0/include/c++/9.5.0/thread:195
#10 0x0000007ff7cb0984 in execute_native_thread_routine () from /nix/store/f01gwicpyspl4qf7h8cwvgzg5x4s2a0g-gcc-9.5.0-lib/lib/libstdc++.so.6
#11 0x0000007ff799bdb4 in start_thread () from /nix/store/yy19vx24hhn7snsv7pffnqh1mknfp1sq-glibc-2.35-224/lib/libc.so.6
#12 0x0000007ff7a0289c in thread_start () from /nix/store/yy19vx24hhn7snsv7pffnqh1mknfp1sq-glibc-2.35-224/lib/libc.so.6

https://wayland.app/protocols/idle-inhibit-unstable-v1 indicates that Sway also supports this extension, and these applications don't crash there.
image

Unsure if relevant to this, but the applications also print the following on startup.

[2023-02-12 23:02:27.012698] < -warning- > mirserver: WlRegion::subtract not implemented. ignoring.
phossil added a commit to phossil/nixfiles that referenced this issue Feb 15, 2023
some SDL games were required for testing Mir, potential bug found in their use of zwp_idle_inhibit_manager_v1\n see here: canonical/mir#2836
@AlanGriffiths
Copy link
Contributor

@OPNA2608, thanks for this. Clearly there are two issues:

  1. SDL2 is not tearing down the window correctly; and,
  2. this should not crash the Mir server.

To help us with reproducing this, could you confirm which version of SDL2 you are using?

@OPNA2608
Copy link
Contributor Author

Nixpkgs unstable currently uses 2.24.2, Ubuntu 22.10 uses 2.24.0+dfsg-1.

@AlanGriffiths
Copy link
Contributor

I'm currently testing on 23.04: that has SDL2 2.26.2.

I tried downloading the latest Taisei release from the website, but this doesn't bind to zwp_idle_inhibit_manager_v1 nor show the symptoms you describe. (It appears to statically link libSDL2, so that may well be an older version)

@AlanGriffiths
Copy link
Contributor

Ah, but I've just reproduced (after several attempts) with Neverputt (from the Ubuntu archive)

@OPNA2608
Copy link
Contributor Author

I've built Taisei from source against 22.10's system libraries, sorry for not stating so before. I also tried building it against a custom SDL2 2.26.2 on NixOS and it still errors there. The static build from their website does not exhibit these problems.

@AlanGriffiths AlanGriffiths self-assigned this Feb 15, 2023
@AlanGriffiths
Copy link
Contributor

OK, this is down to a flawed implementation in Mir of zwp_idle_inhibit_manager_v1.create_inhibitor.

With SDL2 clients this is called when the surface hasn't been mapped, so the Mir code (for reasons unknown) doesn't create an zwp_idle_inhibitor_v1.

When the client subsequently destroys the zwp_idle_inhibitor_v1 that it (quite reasonably) thinks was created Mir can't find the object it is trying to destroy.

@bors bors bot closed this as completed in 5f634e3 Feb 21, 2023
Saviq pushed a commit that referenced this issue Feb 23, 2023
2842: (Sophie's) reimplementation of idle_inhibit_unstable_v1 r=AlanGriffiths a=wmww

Based on and alternative to #2839. I put the visibility observer in idle_inhibit_v1.cpp to avoid cluttering wl_surface.cpp. Draft since there's still some issues I've observed and want to sort out. Not yet clear if they're also in our current implementation and/or Alan's implementation.

Fixes #2838
Fixes #2836

Co-authored-by: Alan Griffiths <alan@octopull.co.uk>
Co-authored-by: Sophie Winter <wm@wmww.sh>
bors bot added a commit that referenced this issue Feb 27, 2023
2846: Release 2.12.1 r=AlanGriffiths a=Saviq

    - Bugs fixed:
      . Add missing #include statements (#2802)
      . mir_wayland_generator generated code that include non public
        header (#2804)
      . Building docs fails when trying to not remove doc/html/cppguide (#2800)
      . wayland: Add missing cstdint includes (#2821)
      . Enabling zwp_idle_inhibit_manager_v1 causes Mir to crash with some
        applications (#2836)
      . [Wayland] idle_inhibit_unstable_v1 is badly broken (#2838)

Co-authored-by: bors[bot] <26634292+bors[bot]@users.noreply.github.com>
Co-authored-by: Michał Sawicz (Saviq) <michal@sawicz.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants