pop-os / cosmic-launcher

WIP
GNU General Public License v3.0
104 stars 56 forks source link

[Bug] Semi-random panics with some prompts #191

Closed fleefie closed 1 month ago

fleefie commented 1 month ago

For example, run cosmic-files, then try looking up "cosmic files" in the launcher. This will lead to a panic preventing launching anything:

thread 'main' panicked at library/core/src/slice/sort/shared/smallsort.rs:862:5:
user-provided comparison function does not correctly implement a total order
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fleefie commented 1 month ago

Update: Seems to be one cause of it, but isn't the entire thing. Just looking up "cosmic settings" sometimes locks up the application launcher too?

fleefie commented 1 month ago

Full backtrace:

stack backtrace:
   0:     0x615afd04377a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h1b9dad2a88e955ff
   1:     0x615afccd180b - core::fmt::write::h4b5a1270214bc4a7
   2:     0x615afd00d4c2 - std::io::Write::write_fmt::hd04af345a50c312d
   3:     0x615afd045cd7 - std::panicking::default_hook::{{closure}}::h96ab15e9936be7ed
   4:     0x615afd046f0f - std::panicking::rust_panic_with_hook::hfe205f6954b2c97b
   5:     0x615afd046742 - std::panicking::begin_panic_handler::{{closure}}::h6cb44b3a50f28c44
   6:     0x615afd0466d9 - std::sys::backtrace::__rust_end_short_backtrace::hf1c1f2a92799bb0e
   7:     0x615afd0466c4 - rust_begin_unwind
   8:     0x615afcc33012 - core::panicking::panic_fmt::h3d8fc78294164da7
   9:     0x615afccd90aa - core::slice::sort::shared::smallsort::panic_on_ord_violation::h4e03188016ac0891
  10:     0x615afce2212c - core::slice::sort::stable::quicksort::quicksort::h36083e7e4a6b28b5
  11:     0x615afce20d89 - core::slice::sort::stable::drift::sort::h0c84f3b4e3462107
  12:     0x615afcdfef52 - core::slice::sort::stable::driftsort_main::h76c7c763b44b1240
  13:     0x615afcd11e21 - pop_launcher_service::Service<O>::finished::{{closure}}::hf57459b5b48428e4
  14:     0x615afcd96e73 - <futures_util::future::select::Select<A,B> as core::future::future::Future>::poll::h600cf74f5f9a8d78
  15:     0x615afcd667ad - <futures_util::future::maybe_done::MaybeDone<Fut> as core::future::future::Future>::poll::h292c48aceaa065e7
  16:     0x615afcc60973 - <futures_util::future::join::Join<Fut1,Fut2> as core::future::future::Future>::poll::h54fd046a9524595c
  17:     0x615afcd13ea0 - pop_launcher_bin::main::{{closure}}::hdc210ad04fb794a1
  18:     0x615afcc7f003 - pop_launcher_bin::main::hb783b42d3c010c5a
  19:     0x615afcdfeb96 - std::sys::backtrace::__rust_begin_short_backtrace::h00335c9a7a0edd75
  20:     0x615afcc8110c - main
  21:     0x7b2d03305e08 - <unknown>
  22:     0x7b2d03305ecc - __libc_start_main
  23:     0x615afcc60875 - _start
  24:                0x0 - <unknown>
wash2 commented 1 month ago

I'm not able to recreate this. Do you know the versions of cosmic-launcher and the launcher service that you have installed?

fleefie commented 1 month ago

I installed cosmic-launcher through the Arch AUR package cosmic-launcher-git, which is based on commit 5c9757b. I'm unsure of how to check which launcher service I'm using. The issue seems to have randomly fixed itself though... But it pops back now and then. I'll try to debug more to see if i can see what starts it.

fleefie commented 1 month ago

I was able to recreate it following those steps:

Example menu:

image

Here typing "O" causes a panic. Erasing and re-typing any valid string prevents launch. Only "O" seems to cause it? Maybe it's related to my .desktop files? https://gist.github.com/fleefie/0dc4281d458a730bda055be4d1d181b5

peterkrull commented 1 month ago

Same here, installed through the fedora copr repo. Just started experiencing it recently.

peterkrull commented 1 month ago

Probably related to a recent change in how improper implementations of Ord are handeled: Citing: https://doc.rust-lang.org/nightly/releases.html

The new sort implementations may panic if a type’s implementation of Ord (or the given comparison function) does not implement a total order as the trait requires. Ord’s supertraits (PartialOrd, Eq, and PartialEq) must also be consistent. The previous implementations would not “notice” any problem, but the new implementations have a good chance of detecting inconsistencies, throwing a panic rather than returning knowingly unsorted data.

skewballfox commented 1 month ago

some relevant system logs:

fedora cosmic-session[3068]: thread 'main' panicked at library/core/src/slice/sort/shared/smallsort.rs:862:5:
fedora cosmic-session[3068]: user-provided comparison function does not correctly implement a total order

followed by a core-dump. the only place I'm seeing a comparison going on in the cosmic-launcher is sorting bools converted to i32s. I think this is coming from SearchResult's sort function, or it's ord, cmp implementations. very much eyeballing that though.

I might be able to take a swing at it sometime this weekend, no worries if someone beats me to it though

mmstick commented 1 month ago

Our CI builds packages with Rust 1.80.1 via rustup, since that's the recommended target right now. Which doesn't contain the sort changes in 1.81

peterkrull commented 1 month ago

I use the copr distribution by @ryanabx, and looking at the build logs I see rust components with version number 1.81

ryanabx commented 1 month ago

I use the copr distribution by @ryanabx, and looking at the build logs I see rust components with version number 1.81

As far as I know the rust version it compiles with is not changeable on my end, because I think fedora packages only one rust version. I'm not sure though, I'll find out.

ryanabx commented 1 month ago

So we can't change the version of rust we're compiling with, sorry!

fleefie commented 1 month ago

Can confirm that this fixed the issue, thanks a bunch!