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

Panics when "focused_window" is the only block configured #534

Closed
ammgws opened this issue Jan 29, 2020 · 1 comment · Fixed by #535
Closed

Panics when "focused_window" is the only block configured #534

ammgws opened this issue Jan 29, 2020 · 1 comment · Fixed by #535

Comments

@ammgws
Copy link
Collaborator

ammgws commented Jan 29, 2020

As per title.

config.toml contents
theme = "solarized-dark"
icons = "awesome"

[[block]]
block = "focused_window"
stdout at time of panic:
{"version": 1, "click_events": true}
[[],
thread 'main' panicked at 'overflow when adding duration to instant', src/libcore/option.rs:1185:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
backtrace:
{"version": 1, "click_events": true}
[[],
thread 'main' panicked at 'overflow when adding duration to instant', src/libcore/option.rs:1185:5
stack backtrace:
   0:     0x557fb6fcace4 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4c5e39dd6bf38933
   1:     0x557fb6fedc8c - core::fmt::write::h94b22f3cbda6422c
   2:     0x557fb6fc79a7 - std::io::Write::write_fmt::he7e02466cb3dc860
   3:     0x557fb6fcd38e - std::panicking::default_hook::{{closure}}::h077f2d0f0f4550db
   4:     0x557fb6fcd081 - std::panicking::default_hook::hcc1ceebfaf9d0a58
   5:     0x557fb6fcda8b - std::panicking::rust_panic_with_hook::h328d8e7ed959397b
   6:     0x557fb6fcd62e - std::panicking::continue_panic_fmt::h745b12464b662c8f
   7:     0x557fb6fcd516 - rust_begin_unwind
   8:     0x557fb6fe9ace - core::panicking::panic_fmt::hdb91b8826feb6fc9
   9:     0x557fb6fe9b37 - core::option::expect_failed::h02ca44b00cc41c7f
  10:     0x557fb6fca879 - <std::time::SystemTime as core::ops::arith::Add<core::time::Duration>>::add::h93fc4eab81208764
  11:     0x557fb6dad0b3 - crossbeam_channel::flavors::after::Channel::new::h7cf3b0b56e89f831
                               at /home/ammgws/.cargo/registry/src/github.com-1ecc6299db9ec823/crossbeam-channel-0.4.0/src/flavors/after.rs:31
  12:     0x557fb6dad020 - crossbeam_channel::channel::after::h5ed64f402a86cc04
                               at /home/ammgws/.cargo/registry/src/github.com-1ecc6299db9ec823/crossbeam-channel-0.4.0/src/channel.rs:177
  13:     0x557fb6889d46 - i3status_rs::run::ha9322434272d2061
                               at src/main.rs:243
  14:     0x557fb688557d - i3status_rs::main::hc785fa21c69d20b9
                               at src/main.rs:87
  15:     0x557fb68f12b0 - std::rt::lang_start::{{closure}}::h4fad3d60d7e957f2
                               at /build/rust/src/rustc-1.40.0-src/src/libstd/rt.rs:61
  16:     0x557fb6fcd4b3 - std::panicking::try::do_call::h81508b6a18a6e157
  17:     0x557fb6fd57ba - __rust_maybe_catch_panic
  18:     0x557fb6fce02d - std::rt::lang_start_internal::hfccf8c6e859ea61a
  19:     0x557fb68f1289 - std::rt::lang_start::h9a863fff0d11033c
                               at /build/rust/src/rustc-1.40.0-src/src/libstd/rt.rs:61
  20:     0x557fb688b5aa - main
  21:     0x7f9203c39153 - __libc_start_main
  22:     0x557fb67a00de - _start
  23:                0x0 - <unknown>

This is what I think is happening:

  • focused_window block only sends updates (tx.send(...)) when it receives an update on the IPC channel
  • main thread expects update_time to have been set by a block, otherwise it sets the timeout to std::u64::MAX which instantly causes the overflow panic to occur

Further investigation:

I changed the above std::u64::MAX to 10 seconds. As long as you keep changing the window focus within 10 seconds, i3status-rs works fine. But if you leave it for 10 seconds you will get the panic below which now points to the scheduler:

backtrace when timeout is set to 10s
{"version": 1, "click_events": true}
[[],
[{"background":null,"color":"#002b36","full_text":"","markup":"pango","separator":false,"separator_block_width":0},{"background":"#002b36","color":"#93a1a1","full_text":" /tmp | fish ","separator":false,"separator_block_width":0}],
[{"background":"#000000","color":"#dc322f","full_text":" Internal error in context 'scheduler': schedule is empty ","separator":false,"separator_block_width":0}]


Internal error in context 'scheduler': schedule is empty
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "SendError(..)"', src/libcore/result.rs:1165:5
stack backtrace:
   0:     0x55c0da414ce4 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4c5e39dd6bf38933
   1:     0x55c0da437c8c - core::fmt::write::h94b22f3cbda6422c
   2:     0x55c0da4119a7 - std::io::Write::write_fmt::he7e02466cb3dc860
   3:     0x55c0da41738e - std::panicking::default_hook::{{closure}}::h077f2d0f0f4550db
   4:     0x55c0da417081 - std::panicking::default_hook::hcc1ceebfaf9d0a58
   5:     0x55c0da417a8b - std::panicking::rust_panic_with_hook::h328d8e7ed959397b
   6:     0x55c0da41762e - std::panicking::continue_panic_fmt::h745b12464b662c8f
   7:     0x55c0da417516 - rust_begin_unwind
   8:     0x55c0da433ace - core::panicking::panic_fmt::hdb91b8826feb6fc9
   9:     0x55c0da433bc7 - core::result::unwrap_failed::haba3c6d5a6de1991
  10:     0x55c0d9c3fdfc - core::result::Result<T,E>::unwrap::h62c1cc4849b4e08a
                               at /build/rust/src/rustc-1.40.0-src/src/libcore/result.rs:933
  11:     0x55c0d9e9a283 - <i3status_rs::blocks::focused_window::FocusedWindow as i3status_rs::blocks::ConfigBlock>::new::{{closure}}::hca064e0f0147e248
                               at src/blocks/focused_window.rs:69
  12:     0x55c0d9ee2000 - std::sys_common::backtrace::__rust_begin_short_backtrace::h49fe9e8f6df29001
                               at /build/rust/src/rustc-1.40.0-src/src/libstd/sys_common/backtrace.rs:129
  13:     0x55c0d9e057d2 - std::thread::Builder::spawn_unchecked::{{closure}}::{{closure}}::hbcaf183d72c49056
                               at /build/rust/src/rustc-1.40.0-src/src/libstd/thread/mod.rs:469
  14:     0x55c0d9dd8822 - <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h861413b3c039f0f8
                               at /build/rust/src/rustc-1.40.0-src/src/libstd/panic.rs:317
  15:     0x55c0d9caa4dc - std::panicking::try::do_call::hf8e4ef7e39c8ba81
                               at /build/rust/src/rustc-1.40.0-src/src/libstd/panicking.rs:287
  16:     0x55c0da41f7ba - __rust_maybe_catch_panic
  17:     0x55c0d9ca8c7e - std::panicking::try::h94b234fb9e84ef30
                               at /build/rust/src/rustc-1.40.0-src/src/libstd/panicking.rs:265
  18:     0x55c0d9dd8b42 - std::panic::catch_unwind::h7bd6e96b94b73647
                               at /build/rust/src/rustc-1.40.0-src/src/libstd/panic.rs:396
  19:     0x55c0d9e02ace - std::thread::Builder::spawn_unchecked::{{closure}}::h2c494a8806a81a27
                               at /build/rust/src/rustc-1.40.0-src/src/libstd/thread/mod.rs:468
  20:     0x55c0d9c77dd3 - core::ops::function::FnOnce::call_once{{vtable.shim}}::hb00a27c0d6380e5b
                               at /build/rust/src/rustc-1.40.0-src/src/libcore/ops/function.rs:227
  21:     0x55c0da40a13f - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h9c0116b07c5d124e
  22:     0x55c0da41ec60 - std::sys::unix::thread::Thread::new::thread_start::h20a61bfd6b1bfdd0
  23:     0x7faa5ba484cf - start_thread
  24:     0x7faa5b95b2d3 - clone
  25:                0x0 - <unknown>

Takeaways:

  1. Should we really be using std::u64::MAX here?

  2. This project seems dependent on each block to be sending updates, so this issue is probably just due to the focused_window block not following the correct pattern.

  3. Note that this panic doesn't occur if you define another block or more alongside focused_window as those block will provide the updates to keep the code in main.rs/scheduler.rs happy.

@ammgws
Copy link
Collaborator Author

ammgws commented Mar 15, 2022

So apparently this was actually a bug with crossbeam_channel: crossbeam-rs/crossbeam#798

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

Successfully merging a pull request may close this issue.

1 participant