samvel1024 / kbct

Keyboard keycode mapping utility for Linux supporting layered configuration
MIT License
272 stars 24 forks source link

kbct mainthread panics/quits when disconnecting wired keyboard #4

Closed seltzered closed 3 years ago

seltzered commented 3 years ago

Thank you sooo much for developing this! Been looking for a cleaner solution for key remapping and this is great.

Noticed a bug when testing with a wired/bluetooth keyboard - when unplugging the USB (or turning my keyboard off to switch back to bluetooth mode), I get the following error:

INFO  kbct > Starting kbct event loop, pid=41913
 INFO  kbct > Capturing device path=/dev/input/event25 name="SONiX USB DEVICE" mapped_name="Kbct-SONiX USB DEVICE"
 INFO  kbct > Ejected device path="/dev/input/event25"
thread 'main' panicked at 'Could not capture keyboard: IOError(Os { code: 2, kind: NotFound, message: "No such file or directory" })', src/main.rs:212:58
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Environment: Ubuntu 21.04 (wayland)

seltzered commented 3 years ago

full backtrace (done by starting with keyboard in bluetooth mode, switching to usb, then switching back to bluetooth (i.e. disconnecting usb and causing error)):

INFO  kbct > Starting kbct event loop, pid=15110
 INFO  kbct > Capturing device path=/dev/input/event21 name="NUTYPE F1 Keyboard" mapped_name="Kbct-NUTYPE F1 Keyboard"
 INFO  kbct > Capturing device path=/dev/input/event26 name="SONiX USB DEVICE" mapped_name="Kbct-SONiX USB DEVICE"

 INFO  kbct > Ejected device path="/dev/input/event26"
thread 'main' panicked at 'Could not capture keyboard: IOError(Os { code: 2, kind: NotFound, message: "No such file or directory" })', src/main.rs:212:58
stack backtrace:
   0:     0x55a01ad61af0 - std::backtrace_rs::backtrace::libunwind::trace::h5e9d00f0cdf4f57e
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x55a01ad61af0 - std::backtrace_rs::backtrace::trace_unsynchronized::hd5302bd66215dab9
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x55a01ad61af0 - std::sys_common::backtrace::_print_fmt::ha0237cd11a34e2bf
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x55a01ad61af0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h171d4c10df1a98ee
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x55a01ad8100c - core::fmt::write::h89e4288724daa3fa
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/fmt/mod.rs:1096:17
   5:     0x55a01ad5e852 - std::io::Write::write_fmt::h6d40f996e84584d9
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/io/mod.rs:1568:15
   6:     0x55a01ad63c35 - std::sys_common::backtrace::_print::h0c0b93221682afc8
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x55a01ad63c35 - std::sys_common::backtrace::print::h57a9f95204c2fdd6
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x55a01ad63c35 - std::panicking::default_hook::{{closure}}::h4245258b50e37e69
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:208:50
   9:     0x55a01ad63793 - std::panicking::default_hook::h7b00dcc1d0944747
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:225:9
  10:     0x55a01ad643d1 - std::panicking::rust_panic_with_hook::h71e6a073d87de1f5
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:591:17
  11:     0x55a01ad63f17 - std::panicking::begin_panic_handler::{{closure}}::hd549436f6bb6dbb8
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:497:13
  12:     0x55a01ad61f8c - std::sys_common::backtrace::__rust_end_short_backtrace::h4e5f4b72b04174c3
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/sys_common/backtrace.rs:141:18
  13:     0x55a01ad63e79 - rust_begin_unwind
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:493:5
  14:     0x55a01ad7f9a1 - core::panicking::panic_fmt::hcd56f7f635f62c74
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/panicking.rs:92:14
  15:     0x55a01ad7f7c3 - core::option::expect_none_failed::hf37eebedadde29e6
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/option.rs:1300:5
  16:     0x55a01a91dbec - core::result::Result<T,E>::expect::h6f4d50364a9eff26
                               at /home/sme/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/result.rs:997:23
  17:     0x55a01a8a3966 - <kbct::DeviceManager as kbct::nio::EventObserver>::on_event::h19a1c27fd17ee60a
                               at /home/sme/src/kbct/src/main.rs:212:5
  18:     0x55a01a875580 - kbct::nio::EventLoop::run::h81776f0a537dbce6
                               at /home/sme/src/kbct/src/nio.rs:46:11
  19:     0x55a01a8a4ec6 - kbct::start_mapper::h4df6ea383a04ddea
                               at /home/sme/src/kbct/src/main.rs:287:2
  20:     0x55a01a8a4680 - kbct::start_mapper_from_file_conf::h6abaeacc14181489
                               at /home/sme/src/kbct/src/main.rs:275:2
  21:     0x55a01a8a5fd9 - kbct::main::hf140f9ed72c3bbb9
                               at /home/sme/src/kbct/src/main.rs:367:4
  22:     0x55a01a8c73d2 - core::ops::function::FnOnce::call_once::h437e19c21ddd9d80
                               at /home/sme/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
  23:     0x55a01a8b278a - std::sys_common::backtrace::__rust_begin_short_backtrace::h6ac56ed2bd5d58d5
                               at /home/sme/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys_common/backtrace.rs:125:18
  24:     0x55a01a8aeb56 - std::rt::lang_start::{{closure}}::ha608ed6b8114b7f3
                               at /home/sme/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:66:18
  25:     0x55a01ad647f7 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h527fb2333ede305e
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/ops/function.rs:259:13
  26:     0x55a01ad647f7 - std::panicking::try::do_call::h309d8aee8149866c
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:379:40
  27:     0x55a01ad647f7 - std::panicking::try::h75a60c31fd16bfc6
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:343:19
  28:     0x55a01ad647f7 - std::panic::catch_unwind::h1f9892423e99bc00
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panic.rs:431:14
  29:     0x55a01ad647f7 - std::rt::lang_start_internal::hd5b67df56ca01dae
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/rt.rs:51:25
  30:     0x55a01a8aeb27 - std::rt::lang_start::h324a23944f56788f
                               at /home/sme/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:65:5
  31:     0x55a01a8a778a - main
  32:     0x7feb9dda2565 - __libc_start_main
  33:     0x55a01a8630ae - _start
  34:                0x0 - <unknown>
samvel1024 commented 3 years ago

Most likely related/duplicate of https://github.com/samvel1024/kbct/issues/6

seltzered commented 3 years ago

Thanks for fixing this! Are there any plans for a new AppImage release soon?