-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Description
I tried this code:
let foo = rusb::Error::Timeout;
println!("Debug: {:?}", foo);
println!("Display: {}", foo);
Running:
cargo run --release --target i686-unknown-linux-gnu
With the following on my Crago.toml:
[package]
name = "test-rusb"
version = "0.1.0"
authors = ["Jonathas-Conceicao <jadoliveira@inf.ufpel.edu.br>"]
edition = "2018"
[profile.release]
opt-level = "z"
panic = "abort"
[dependencies]
rusb = "=0.5.4"
I expected to see this happen: Cross-compiling to a i686 and running should work on my machine as I do have the required dependencies installed. Both the Debug and Display should be printable without a problem as the type supports both.
Instead, this happened: The type's Display resulted on a "Segmentation fault".
Why do I think this is a rustc issue and not a rusb one
Lower levels of optimization and not using "panic = abort", or setting both on the "profile.dev" didn't cause a panic.
Although the problem is only happening with rusb::Error
I have taken a look at it and it doesn't seem to be doing nothing fuzzy.
In my tests I did notice that changing the strerror type signature from:
pub fn strerror(self) -> &'static str {
to
pub fn strerror(&self) -> &'static str {
Did stop the "Segmentation fault" from happening. But as the type derives Copy
I don't think this should be a problem.
I have, however, tried to isolate those piece of code on a isolated example for testing, but I wasn't able to reproduce the problem there, that's why I'm reporting this using rusb itself.
Meta
rustc --version --verbose
:
rustc 1.45.0-nightly (a74d1862d 2020-05-14)
binary: rustc
commit-hash: a74d1862d4d87a56244958416fd05976c58ca1a8
commit-date: 2020-05-14
host: x86_64-unknown-linux-gnu
release: 1.45.0-nightly
LLVM version: 9.0