Skip to content

Iterator chain windows().enumerate().filter_map() causes segfault on x86 no_std targets #143200

Closed
@bubblepipe

Description

@bubblepipe

I tried this code:

let data: [bool; 4] = [false, true, false, false];
let mut iter = data
    .windows(1)
    .enumerate()
    .filter_map(|(i, _)| Some(i));
        
// THIS WILL CRASH ON X86
let _ = iter.next();

I expected to see this happen: it would not crash

Instead, this happened: it crashes

Meta

rustc 1.87.0 (17067e9ac 2025-05-09)
binary: rustc
commit-hash: 17067e9ac6d7ecb70e50f92c1944e545188d2359
commit-date: 2025-05-09
host: aarch64-apple-darwin
release: 1.87.0
LLVM version: 20.1.1

I have created a testbench https://github.com/bubblepipe/rust-nostd-x86-iter-crash/blob/main/qemu to replicate this crash.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-discussionCategory: Discussion or questions that doesn't represent real issues.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions