Skip to content

invalid opcode regression in x86_64-unknown-linux-musl release builds while compiling code using generic-array #135997

Closed
@SohumB

Description

@SohumB

Repro.

searched nightlies: from nightly-2024-11-21 to nightly-2025-01-24
regressed nightly: nightly-2025-01-10
searched commit range: a580b5c...8247594
regressed commit: b6b8361

bisected with cargo-bisect-rustc v0.6.9

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc -vv --start=2024-11-21 --target=x86_64-unknown-linux-musl --script=run.sh

I definitely don't understand MIR, but I was curious enough to look at it, so in case it helps anyone else, here's what appears to be the relevant section (without the StorageLive/StorageDead calls)

succeeding
        _2 = copy (_1.0: Box<GenericArray<usize, U1>>);

        _3 = copy (((_2.0: Unique<GenericArray<usize, U1>>).0: NonNull<GenericArray<usize, U1>>).0: 
                    *const GenericArray<usize, U1>);

        _4 = *const [usize] from (copy _3, const 1_usize);
        _6 = NonNull::<[usize]> { pointer: copy _4 };
        _11 = copy _6 as *mut [usize] (Transmute);
        _10 = copy _11 as *const usize (PtrToPtr);

        _5 = NonNull::<usize> { pointer: move _10 };
        _9 = copy _5 as *mut usize (Transmute);
        _8 = Offset(copy _9, const 1_usize);
        _7 = move _8 as *const usize (PtrToPtr);
        drop(_1) -> [return: bb2, unwind continue];
failing
        _2 = copy (_1.0: Box<GenericArray<usize, U1>>);

        _3 = copy ((_2.0: Unique<GenericArray<usize, U1>>).0: NonNull<GenericArray<usize, U1>>) 
                    as *const GenericArray<usize, U1> (Transmute);

        _4 = *const [usize] from (copy _3, const 1_usize);
        _9 = copy _4 as *const usize (Transmute);

        _5 = NonNull::<usize> { pointer: move _9 };
        _8 = copy _4 as *mut usize (Transmute);
        _7 = Offset(copy _8, const 1_usize);
        _6 = move _7 as *const usize (PtrToPtr);
        drop(_1) -> [return: bb2, unwind continue];

Metadata

Metadata

Labels

A-mir-optArea: MIR optimizationsA-mir-opt-GVNArea: MIR opt Global Value Numbering (GVN)C-bugCategory: This is a bug.I-miscompileIssue: Correct Rust code lowers to incorrect machine codeO-muslTarget: The musl libcP-criticalCritical 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