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

Fix lints introduced by clippy 1.78 to 1.80 #188

Merged
merged 3 commits into from
Aug 21, 2024
Merged

Fix lints introduced by clippy 1.78 to 1.80 #188

merged 3 commits into from
Aug 21, 2024

Conversation

strohel
Copy link
Member

@strohel strohel commented Jun 27, 2024

  • Check test_all.sh is passed: Hmm, they don't. I'm getting:
    test examples/u3v/register_map.rs ... error
    Test case failed at runtime.
    
    STDERR:
    ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
    warning: `/home/strohel/work/cameleon/.cargo/config` is deprecated in favor of `config.toml`
    note: if you need to support cargo 1.38 or earlier, you can symlink `config` to `config.toml`
    thread 'main' panicked at library/core/src/panicking.rs:220:5:
    unsafe precondition(s) violated: slice::from_raw_parts requires the pointer to be aligned and non-null, and the total size of the slice not to exceed `isize::MAX`
    stack backtrace:
       0: rust_begin_unwind
       1: core::panicking::panic_nounwind_fmt
       2: core::panicking::panic_nounwind
       3: core::slice::raw::from_raw_parts::precondition_check
                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/ub_checks.rs:66:21
       4: core::slice::raw::from_raw_parts
                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/ub_checks.rs:73:17
       5: rusb::interface_descriptor::InterfaceDescriptor::endpoint_descriptors
                 at /home/strohel/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rusb-0.9.3/src/interface_descriptor.rs:95:13
       6: cameleon_device::u3v::device_builder::DeviceBuilder::find_u3v_iad_in_if_desc
                 at /home/strohel/work/cameleon/device/src/u3v/device_builder.rs:166:24
       7: cameleon_device::u3v::device_builder::DeviceBuilder::find_u3v_iad_in_config_desc
                 at /home/strohel/work/cameleon/device/src/u3v/device_builder.rs:150:40
       8: cameleon_device::u3v::device_builder::DeviceBuilder::find_u3v_iad
                 at /home/strohel/work/cameleon/device/src/u3v/device_builder.rs:133:36
       9: cameleon_device::u3v::device_builder::DeviceBuilder::new
                 at /home/strohel/work/cameleon/device/src/u3v/device_builder.rs:50:45
      10: cameleon_device::u3v::device_builder::enumerate_devices::{{closure}}
                 at /home/strohel/work/cameleon/device/src/u3v/device_builder.rs:29:27
      11: core::iter::adapters::filter_map::filter_map_try_fold::{{closure}}
                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/iter/adapters/filter_map.rs:49:28
      12: core::iter::traits::iterator::Iterator::try_fold
                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/iter/traits/iterator.rs:2410:21
      13: <core::iter::adapters::filter_map::FilterMap<I,F> as core::iter::traits::iterator::Iterator>::try_fold
                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/iter/adapters/filter_map.rs:140:9
      14: core::iter::traits::iterator::Iterator::find_map
                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/iter/traits/iterator.rs:2912:9
      15: <core::iter::adapters::filter_map::FilterMap<I,F> as core::iter::traits::iterator::Iterator>::next
                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/iter/adapters/filter_map.rs:64:9
      16: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter_nested::SpecFromIterNested<T,I>>::from_iter
                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/alloc/src/vec/spec_from_iter_nested.rs:26:32
      17: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/alloc/src/vec/spec_from_iter.rs:33:9
      18: <alloc::vec::Vec<T> as core::iter::traits::collect::FromIterator<T>>::from_iter
                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/alloc/src/vec/mod.rs:2972:9
      19: core::iter::traits::iterator::Iterator::collect
                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/iter/traits/iterator.rs:2004:9
      20: cameleon_device::u3v::device_builder::enumerate_devices
                 at /home/strohel/work/cameleon/device/src/u3v/device_builder.rs:31:8
      21: cameleon::u3v::enumerate_cameras
                 at /home/strohel/work/cameleon/cameleon/src/u3v/mod.rs:76:19
      22: trybuild000::main
                 at /home/strohel/work/cameleon/cameleon/examples/u3v/register_map.rs:11:23
      23: core::ops::function::FnOnce::call_once
                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/ops/function.rs:250:5
    note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
    thread caused non-unwinding panic. aborting.
    ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
    
    Looks like unrelated possibly safety issue?
  • Add fix #{ISSUE_NUMBER} if the corresponding issue exists.
  • Fill out ## Changelog section. If the change is for only internal use, please write None to the section.

Changelog

None

@strohel strohel requested review from bschwind and Y-Nak June 27, 2024 08:40
Copy link
Contributor

@bschwind bschwind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@strohel the test script passes for me on my machine, but the error from yours is a bit scary! Does it pass for you on main?

@strohel
Copy link
Member Author

strohel commented Jul 5, 2024

@bschwind yeah I also get it on main if I comment out # -- -D warnings in test_all.sh to make it get past compilation.

I was on nightly, but I tried on rust 1.79 stable, and got the same error. Maybe this could be Linux-specific?

@mbernat could you please try cloning the cameleon repo on your beefy Linux laptop and running ./test_all.sh?

@mbernat
Copy link

mbernat commented Aug 8, 2024

@strohel will do. Somehow I completely missed this notification, sorry! 🙇

@mbernat
Copy link

mbernat commented Aug 8, 2024

I'm getting the same error, as expected.

thread 'main' panicked at library/core/src/panicking.rs:220:5:
unsafe precondition(s) violated: slice::from_raw_parts requires the pointer to be aligned and non-null, and the total size of the slice not to exceed `isize::MAX`

@strohel
Copy link
Member Author

strohel commented Aug 19, 2024

Alright, I was able to debug the panic a bit more.

The problem itself was a bug in rusb <= 0.9.3, fixed in rusb 0.9.4 in a1ien/rusb#195

But I was not getting the newer rusb even when running cargo update -v:

strohel@thicky ~/work/cameleon $ cargo update --verbose
warning: `/home/strohel/work/cameleon/.cargo/config` is deprecated in favor of `config.toml`
note: if you need to support cargo 1.38 or earlier, you can symlink `config` to `config.toml`
    Updating crates.io index
     Locking 0 packages to latest compatible versions
   Unchanged ahash v0.7.8 (latest: v0.8.11)
   Unchanged ambassador v0.2.1 (latest: v0.4.1)
   Unchanged async-channel v1.9.0 (latest: v2.3.1)
   Unchanged event-listener v2.5.3 (latest: v5.3.1)
   Unchanged generic-array v0.14.7 (latest: v1.1.0)
   Unchanged hashbrown v0.11.2 (latest: v0.14.5)
   Unchanged idna v0.5.0 (latest: v1.0.2)
   Unchanged libusb1-sys v0.6.5 (latest: v0.7.0)
   Unchanged miniz_oxide v0.7.4 (latest: v0.8.0)
   Unchanged roxmltree v0.15.1 (latest: v0.20.0)
   Unchanged rusb v0.9.3 (latest: v0.9.4)
   Unchanged string-interner v0.14.0 (latest: v0.17.0)
   Unchanged syn v1.0.109 (latest: v2.0.75)
   Unchanged wasi v0.11.0+wasi-snapshot-preview1 (latest: v0.13.2+wasi-0.2.1)
   Unchanged zip v0.6.6 (latest: v2.1.6)

The reason surfaced when I tried to force 0.9.3 by explicitly bumping the dependency:

    Updating crates.io index
error: failed to select a version for `libusb1-sys`.
    ... required by package `cameleon-device v0.1.12 (/home/strohel/work/cameleon/device)`
    ... which satisfies path dependency `cameleon-device` of package `cameleon v0.1.12 (/home/strohel/work/cameleon/cameleon)`
    ... which satisfies path dependency `cameleon` of package `cameleon-gentl v0.1.12 (/home/strohel/work/cameleon/gentl)`
versions that meet the requirements `^0.6.0` are: 0.6.5, 0.6.4, 0.6.3, 0.6.2, 0.6.1, 0.6.0

the package `libusb1-sys` links to the native library `usb-1.0`, but it conflicts with a previous package which links to `usb-1.0` as well:
package `libusb1-sys v0.7.0`
    ... which satisfies dependency `libusb1-sys = "^0.7"` of package `rusb v0.9.4`
    ... which satisfies dependency `rusb = "^0.9.4"` of package `cameleon-device v0.1.12 (/home/strohel/work/cameleon/device)`
    ... which satisfies path dependency `cameleon-device` of package `cameleon v0.1.12 (/home/strohel/work/cameleon/cameleon)`
    ... which satisfies path dependency `cameleon` of package `cameleon-gentl v0.1.12 (/home/strohel/work/cameleon/gentl)`
Only one package in the dependency graph may specify the same links value. This helps ensure that only one copy of a native library is linked in the final binary. Try to adjust your dependencies so that only one package uses the `links = "usb-1.0"` value. For more information, see https://doc.rust-lang.org/cargo/reference/resolver.html#links.

failed to select a version for `libusb1-sys` which could resolve this conflict

-> the solution is to update libusb1-sys -> I'll file a separate PR.

strohel added a commit that referenced this pull request Aug 19, 2024
...which fixes a panic in dev builds / undefined behavior in release builds: a1ien/rusb#195

See #188 (comment) and above.
strohel added a commit that referenced this pull request Aug 19, 2024
...which fixes a panic in dev builds / undefined behavior in release builds: a1ien/rusb#195

See #188 (comment) and above.
@strohel strohel changed the title Fix lints introduced by clippy 1.78 and 1.79 Fix lints introduced by clippy 1.78 to 1.80 Aug 19, 2024
Copy link
Member

@Y-Nak Y-Nak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks!

@Y-Nak Y-Nak merged commit d83eb5e into main Aug 21, 2024
5 checks passed
@Y-Nak Y-Nak deleted the fix-clippy-1.79 branch August 21, 2024 13:33
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.

4 participants