Skip to content

Segfault when displaying a error from rusb crate on 32bits #73151

@Jonathas-Conceicao

Description

@Jonathas-Conceicao

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessO-x86_32Target: x86 processors, 32 bit (like i686-*) (also known as IA-32, i386, i586, i686)P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions