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

linux: Fix STATE_ABANDONED value #9

Merged
merged 1 commit into from
Oct 31, 2023

Conversation

Dirbaio
Copy link
Contributor

@Dirbaio Dirbaio commented Oct 31, 2023

This seems wrong, unless it's intentional for some reason?

@kevinmehall
Copy link
Owner

Not intentional, but none of the match statements actually distinguish those two (which is why there was no "unreachable pattern" warning), so I'm not sure it caused any problem. Better to have them separate as a check for being in an unexpected state, though. Thanks!

@kevinmehall kevinmehall merged commit b63fc97 into kevinmehall:main Oct 31, 2023
2 checks passed
@Dirbaio
Copy link
Contributor Author

Dirbaio commented Oct 31, 2023

I found this while trying to debug this error I'm seeing randomly. Do you think it could be related? probe-rs code is here if you're curious.

I haven't seen it after this fix, but the error is very very rare so I don't know if it's fixed yet...

Oct 31 14:25:23 venus teleprobe[3206744]:  ERROR panic             > thread 'tokio-runtime-worker' panicked at 'Completing transfer in unexpected state 144': /home/dirbaio/probe-rs/nusb/src/transfer/internal.rs:193
Oct 31 14:25:23 venus teleprobe[3206744]:    0: <backtrace::capture::Backtrace as core::default::Default>::default
Oct 31 14:25:23 venus teleprobe[3206744]:              at /home/dirbaio/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/capture.rs:410:9
Oct 31 14:25:23 venus teleprobe[3206744]:    1: teleprobe::logutil::log_panics::Config::install_panic_hook::{{closure}}
Oct 31 14:25:23 venus teleprobe[3206744]:              at /home/dirbaio/embassy/teleprobe/teleprobe/src/logutil.rs:220:33
Oct 31 14:25:23 venus teleprobe[3206744]:    2: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
Oct 31 14:25:23 venus teleprobe[3206744]:              at /rustc/e0d7ed1f453fb54578cc96dfea859b0e7be15016/library/alloc/src/boxed.rs:2021:9
Oct 31 14:25:23 venus teleprobe[3206744]:       std::panicking::rust_panic_with_hook
Oct 31 14:25:23 venus teleprobe[3206744]:              at /rustc/e0d7ed1f453fb54578cc96dfea859b0e7be15016/library/std/src/panicking.rs:735:13
Oct 31 14:25:23 venus teleprobe[3206744]:    3: std::panicking::begin_panic_handler::{{closure}}
Oct 31 14:25:23 venus teleprobe[3206744]:              at /rustc/e0d7ed1f453fb54578cc96dfea859b0e7be15016/library/std/src/panicking.rs:609:13
Oct 31 14:25:23 venus teleprobe[3206744]:    4: std::sys_common::backtrace::__rust_end_short_backtrace
Oct 31 14:25:23 venus teleprobe[3206744]:              at /rustc/e0d7ed1f453fb54578cc96dfea859b0e7be15016/library/std/src/sys_common/backtrace.rs:170:18
Oct 31 14:25:23 venus teleprobe[3206744]:    5: rust_begin_unwind
Oct 31 14:25:23 venus teleprobe[3206744]:              at /rustc/e0d7ed1f453fb54578cc96dfea859b0e7be15016/library/std/src/panicking.rs:597:5
Oct 31 14:25:23 venus teleprobe[3206744]:    6: core::panicking::panic_fmt
Oct 31 14:25:23 venus teleprobe[3206744]:              at /rustc/e0d7ed1f453fb54578cc96dfea859b0e7be15016/library/core/src/panicking.rs:72:14
Oct 31 14:25:23 venus teleprobe[3206744]:    7: nusb::transfer::internal::notify_completion
Oct 31 14:25:23 venus teleprobe[3206744]:              at /home/dirbaio/probe-rs/nusb/src/transfer/internal.rs:193:18
Oct 31 14:25:23 venus teleprobe[3206744]:    8: nusb::platform::linux_usbfs::device::LinuxInterface::submit_urb
Oct 31 14:25:23 venus teleprobe[3206744]:              at /home/dirbaio/probe-rs/nusb/src/platform/linux_usbfs/device.rs:158:17
Oct 31 14:25:23 venus teleprobe[3206744]:    9: nusb::transfer::internal::TransferHandle<P>::submit
Oct 31 14:25:23 venus teleprobe[3206744]:              at /home/dirbaio/probe-rs/nusb/src/transfer/internal.rs:120:13
Oct 31 14:25:23 venus teleprobe[3206744]:       nusb::device::Interface::control_in
Oct 31 14:25:23 venus teleprobe[3206744]:              at /home/dirbaio/probe-rs/nusb/src/device.rs:111:9
Oct 31 14:25:23 venus teleprobe[3206744]:   10: <nusb::device::Interface as probe_rs::probe::usb_util::InterfaceExt>::read_control::{{closure}}
Oct 31 14:25:23 venus teleprobe[3206744]:              at /home/dirbaio/probe-rs/probe-rs/src/probe/usb_util.rs:18:24
Oct 31 14:25:23 venus teleprobe[3206744]:       <futures_lite::future::Or<F1,F2> as core::future::future::Future>::poll
Oct 31 14:25:23 venus teleprobe[3206744]:              at /home/dirbaio/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-lite-1.13.0/src/future.rs:526:33
Oct 31 14:25:23 venus teleprobe[3206744]:   11: async_io::driver::block_on::{{closure}}
Oct 31 14:25:23 venus teleprobe[3206744]:              at /home/dirbaio/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-io-2.1.0/src/driver.rs:181:37
Oct 31 14:25:23 venus teleprobe[3206744]:       std::thread::local::LocalKey<T>::try_with
Oct 31 14:25:23 venus teleprobe[3206744]:              at /rustc/e0d7ed1f453fb54578cc96dfea859b0e7be15016/library/std/src/thread/local.rs:270:16
Oct 31 14:25:23 venus teleprobe[3206744]:       std::thread::local::LocalKey<T>::with
Oct 31 14:25:23 venus teleprobe[3206744]:              at /rustc/e0d7ed1f453fb54578cc96dfea859b0e7be15016/library/std/src/thread/local.rs:246:9
Oct 31 14:25:23 venus teleprobe[3206744]:       async_io::driver::block_on
Oct 31 14:25:23 venus teleprobe[3206744]:              at /home/dirbaio/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-io-2.1.0/src/driver.rs:157:11
Oct 31 14:25:23 venus teleprobe[3206744]:   12: <nusb::device::Interface as probe_rs::probe::usb_util::InterfaceExt>::read_control
Oct 31 14:25:23 venus teleprobe[3206744]:              at /home/dirbaio/probe-rs/probe-rs/src/probe/usb_util.rs:24:9
Oct 31 14:25:23 venus teleprobe[3206744]:       probe_rs::probe::cmsisdap::tools::read_interface_string
Oct 31 14:25:23 venus teleprobe[3206744]:              at /home/dirbaio/probe-rs/probe-rs/src/probe/cmsisdap/tools.rs:82:16
Oct 31 14:25:23 venus teleprobe[3206744]:   13: probe_rs::probe::cmsisdap::tools::get_cmsisdap_info
Oct 31 14:25:23 venus teleprobe[3206744]:              at /home/dirbaio/probe-rs/probe-rs/src/probe/cmsisdap/tools.rs:111:40
Oct 31 14:25:23 venus teleprobe[3206744]:   14: probe_rs::probe::cmsisdap::tools::list_cmsisdap_devices::{{closure}}
Oct 31 14:25:23 venus teleprobe[3206744]:              at /home/dirbaio/probe-rs/probe-rs/src/probe/cmsisdap/tools.rs:27:34
Oct 31 14:25:23 venus teleprobe[3206744]:       core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
Oct 31 14:25:23 venus teleprobe[3206744]:              at /rustc/e0d7ed1f453fb54578cc96dfea859b0e7be15016/library/core/src/ops/function.rs:294:13
Oct 31 14:25:23 venus teleprobe[3206744]:   15: core::iter::traits::iterator::Iterator::find_map::check::{{closure}}
Oct 31 14:25:23 venus teleprobe[3206744]:              at /rustc/e0d7ed1f453fb54578cc96dfea859b0e7be15016/library/core/src/iter/traits/iterator.rs:2957:32
Oct 31 14:25:23 venus teleprobe[3206744]:       core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
Oct 31 14:25:23 venus teleprobe[3206744]:              at /rustc/e0d7ed1f453fb54578cc96dfea859b0e7be15016/library/core/src/ops/function.rs:294:13
Oct 31 14:25:23 venus teleprobe[3206744]:       core::iter::traits::iterator::Iterator::try_fold
Oct 31 14:25:23 venus teleprobe[3206744]:              at /rustc/e0d7ed1f453fb54578cc96dfea859b0e7be15016/library/core/src/iter/traits/iterator.rs:2461:21

@kevinmehall
Copy link
Owner

Fixed the UB / panic in #10. It's triggered when handling a failure from the syscall to submit a transfer, so you still have that error, but now you'll get a completion with an error status instead of a crash.

tuna-f1sh pushed a commit to tuna-f1sh/nusb that referenced this pull request Sep 26, 2024
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 this pull request may close these issues.

2 participants