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

panic in cosmic-comp @ 6eb8b82 when launching flatpak apps with wayland socket permission #247

Closed
jokeyrhyme opened this issue Dec 16, 2023 · 10 comments

Comments

@jokeyrhyme
Copy link
Contributor

jokeyrhyme commented Dec 16, 2023

Howdie, thanks for sharing this project! I'm so excited! <3

I've just been preparing a PR to bump the git submodules over in cosmic-epoch, and I've noticed that I don't seem to be able to launch Firefox (in flatpak) or Chrome (in flatpak)

GNOME Clocks works, and so does alacritty, so it's not all apps

I haven't narrowed it down to whether or not it's flatpak, but I do have a stack trace:

Dec 16 16:46:15 HOSTNAME systemd[4874]: Started app-flatpak-org.mozilla.firefox-8278.scope.
Dec 16 16:46:15 HOSTNAME cosmic-comp[7530]: thread 'main' panicked at 'called `Option::unwrap()` on a `None` value': src/backend/kms/socket.rs:53
                                               0: <backtrace::capture::Backtrace as core::default::Default>::default
                                               1: log_panics::Config::install_panic_hook::{{closure}}
                                               2: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
                                                         at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/alloc/src/boxed.rs:1987:9
                                                  std::panicking::rust_panic_with_hook
                                                         at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:695:13
                                               3: std::panicking::begin_panic_handler::{{closure}}
                                                         at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:580:13
                                               4: std::sys_common::backtrace::__rust_end_short_backtrace
                                                         at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:150:18
                                               5: rust_begin_unwind
                                                         at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:578:5
                                               6: core::panicking::panic_fmt
                                                         at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:67:14
                                               7: core::panicking::panic
                                                         at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:117:5
                                               8: cosmic_comp::backend::kms::socket::<impl cosmic_comp::state::State>::create_socket::{{closure}}
                                               9: <wayland_server::global::GlobalData<I,U,D> as wayland_backend::sys::server::GlobalHandler<D>>::can_view
                                              10: <unknown>
                                              11: <unknown>
                                              12: <unknown>
                                              13: ffi_call
                                              14: <unknown>
                                              15: <unknown>
                                              16: wl_event_loop_dispatch
                                              17: <core::cell::RefCell<calloop::sources::DispatcherInner<S,F>> as calloop::sources::EventDispatcher<Data>>::process_events
                                              18: cosmic_comp::main
                                              19: std::sys_common::backtrace::__rust_begin_short_backtrace
                                              20: std::rt::lang_start::{{closure}}
                                              21: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
                                                         at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/ops/function.rs:287:13
                                                  std::panicking::try::do_call
                                                         at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:485:40
                                                  std::panicking::try
                                                         at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:449:19
                                                  std::panic::catch_unwind
                                                         at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panic.rs:140:14
                                                  std::rt::lang_start_internal::{{closure}}
                                                         at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/rt.rs:148:48
                                                  std::panicking::try::do_call
                                                         at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:485:40
                                                  std::panicking::try
                                                         at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:449:19
                                                  std::panic::catch_unwind
                                                         at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panic.rs:140:14
                                                  std::rt::lang_start_internal
                                                         at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/rt.rs:148:20
                                              22: main
                                              23: <unknown>
                                              24: __libc_start_main
                                              25: _start
Dec 16 16:46:15 HOSTNAME cosmic-comp[7530]: Failed to clear plane plane::Handle(58) on crtc::Handle(79): DRM access error: Failed to commit on clear_plane on device `Some("/dev/dri/card1")` (Invalid argument (os error 22))

That's with this commit: 6eb8b82

And I believe the panic is from the unwrap() on this line:

let dev_id = normal_client.drm_node.unwrap();

I'm on a fairly recent system with an AMD CPU, AMD iGPU, and AMD dGPU, running Arch Linux

Anyhow, I'm mostly posting this just in case someone else runs into the same thing, and so that I have an issue I can point at from the submodules PR

I understand that COSMIC is pre-alpha, and this might very well be expected for now

@jokeyrhyme
Copy link
Contributor Author

Okay, I tried out this cosmic-epoch commit again: pop-os/cosmic-epoch@cd10271

That has a submodule reference to f6ea7fa

Anyhow, that does launch, and can run Firefox in flatpak, helvum in flatpak, Minecraft in flatpak, GNOME Console, GNOME Clocks, etc without the panic

I'll try a few more cosmic-epoch commits in a sort of bisect and see if I can work it out

@jokeyrhyme
Copy link
Contributor Author

I just tried pop-os/cosmic-epoch@e67428f which has a submodule reference to https://github.com/pop-os/cosmic-comp/commits/db3e372b8f81f174513b4a9f82a876d267d0145c

That's also completely fine here, hmmm....

@jokeyrhyme
Copy link
Contributor Author

I tried pop-os/cosmic-epoch@543abf1 which references 809eeaf and that's also completely fine

I'm starting to wonder if I imagined the panic somehow...

@jokeyrhyme
Copy link
Contributor Author

I just tried pop-os/cosmic-epoch@4fd53f7 which references b33c1dc

I can once again reproduce the crash with Firefox in flatpak (same stack trace as in the original report)

Although, Element in flatpak and Discord in flatpak do work fine, so it's not a problem that is specific to flatpaks

@jokeyrhyme jokeyrhyme changed the title panic in cosmic-comp @ 6eb8b82 when launching Firefox and other apps (but not alacritty) panic in cosmic-comp @ 6eb8b82 when launching flatpak apps with wayland socket permission Dec 17, 2023
@jokeyrhyme
Copy link
Contributor Author

Okay, after playing around with this a bit, I can get Firefox in flatpak and Chrome in flatpak to work without crashing the entire compositor, but only if I block their wayland socket permissions in flatpak, e.g. flatpak override --nosocket=wayland --user org.mozilla.firefox

This does cause them to run in Xwayland mode which is a downside, but the upside is they don't cause cosmic-comp to crash

Separately, I tried cleaning up the nVidia vulkan drivers on my system (leftovers from an old experiment, I don't have an nVidia GPU in there at all now), and I also tried disabling the AMD iGPU, and neither of these had any effect

@Drakulix
Copy link
Member

So far I haven't been able to replicate this, but that might just be, because my packages are not recent enough.

My theory is, that this is a subtle error in our security-context implementation, that is now triggered by the latest version of flatpak making use of that protocol.
Can you try this branch and see, if that fixes it? #250

@jokeyrhyme
Copy link
Contributor Author

@Drakulix yep, amazing

I can confirm that this patch resolves the issue

Firefox-in-flatpak loads just fine now when it had permission to access the wayland socket, with flatpak 1.15.6

@Drakulix
Copy link
Member

Thanks for testing, the fix is merged. That should unblock pop-os/cosmic-epoch#158 now.

@jokeyrhyme
Copy link
Contributor Author

This was broken in epoch even prior to my chore PR

But I'll update my chore PR to carry this latest commit :)

@jokeyrhyme
Copy link
Contributor Author

Fixed by #250

And epoch PR updated to include this: pop-os/cosmic-epoch#158

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants