pop-os / cosmic-comp

Compositor for the COSMIC desktop environment
GNU General Public License v3.0
418 stars 51 forks source link

panic at `attempt to calculate the remainder with a divisor of zero': src/backend/render/cursor.rs:118 #535

Closed michaelBelsanti closed 4 days ago

michaelBelsanti commented 1 month ago

This error is occurring for me whenever cosmic-comp is started, crashing a second later. I am running Cosmic using nixos-cosmic.

cosmic-comp terminal output ``` 1 │ 2024-06-01T17:25:54.717203Z ERROR cosmic_comp::config: Failed to read config 'workspaces' err=NoConfigDirectory 2 │ 2024-06-01T17:25:54.717373Z WARN cosmic_comp::config::types: Key-Binding 'Period' only matched case insensitive for "period" 3 │ 2024-06-01T17:25:54.717390Z WARN cosmic_comp::config::types: Key-Binding 'Comma' only matched case insensitive for "comma" 4 │ 2024-06-01T17:25:54.717399Z WARN cosmic_comp::config::types: Key-Binding 'Period' only matched case insensitive for "period" 5 │ 2024-06-01T17:25:54.717408Z WARN cosmic_comp::config::types: Key-Binding 'Comma' only matched case insensitive for "comma" 6 │ 2024-06-01T17:25:54.955491Z WARN smithay::backend::drm::device::fd: Unable to become drm master, assuming unprivileged mode 7 │ 2024-06-01T17:25:55.025242Z ERROR panic: thread 'main' panicked at 'attempt to calculate the remainder with a divisor of zero': src/backend/render/cursor.rs:118 8 │ 0: ::default 9 │ 1: log_panics::Config::install_panic_hook::{{closure}} 10 │ 2: std::panicking::rust_panic_with_hook 11 │ 3: std::panicking::begin_panic_handler::{{closure}} 12 │ 4: std::sys_common::backtrace::__rust_end_short_backtrace 13 │ 5: rust_begin_unwind 14 │ 6: core::panicking::panic_fmt 15 │ 7: core::panicking::panic 16 │ 8: cosmic_comp::backend::render::cursor::Cursor::get_image 17 │ 9: cosmic_comp::backend::render::cursor::draw_cursor 18 │ 10: cosmic_comp::backend::render::workspace_elements 19 │ 11: cosmic_comp::backend::kms::Surface::render_output 20 │ 12: > as calloop::sources::EventDispatcher>::process_events 21 │ 13: calloop::loop_logic::EventLoop::run 22 │ 14: cosmic_comp::main 23 │ 15: std::sys_common::backtrace::__rust_begin_short_backtrace 24 │ 16: main 25 │ 17: __libc_start_call_main 26 │ 18: __libc_start_main@@GLIBC_2.34 27 │ 19: _start ```
michaelBelsanti commented 1 month ago

Turns out my cursor (posy cursors) and the backup I tried when troubleshooting (phinger cursors) both have some problems. When parsed using the xcursor library used here, the Images created all have a delay of zero, which in this case caused a division by zero.

https://github.com/pop-os/cosmic-comp/blob/cbca13803cb499786b080ea9e4ee74cd4f704556/src/backend/render/cursor.rs#L117-L118

michaelBelsanti commented 1 month ago

Not sure exactly how this delay value is used, so I don't know what a proper fallback would be here, but I would guess a default value could be used instead.

Drakulix commented 1 month ago

Not sure exactly how this delay value is used, so I don't know what a proper fallback would be here, but I would guess a default value could be used instead.

A default value of 0 would be fine (which would resolve to the first image of the cursor theme). A PR to fix this would be very welcome. In any case thanks for debugging this!

Drakulix commented 4 days ago

Fixed with https://github.com/pop-os/cosmic-comp/commit/16691581ff7dcdb7648cc2dbec8cf9d2ad86e36a