Skip to content

Compiler recursion guard warning bypass via closures #149091

@HackingRepo

Description

@HackingRepo

Hello, The rust team

I try the fallowing code

fn call<F: Fn()>(f: F) -> () {
    f();
}

fn main() {
    call(|| {
        self::main();
    });
}

or

fn main() {
    let a = || {
        self::main()
    };
    a();
}

I get PS E:\Programming\Rust\testrust> cargo run

thread 'main' (18180) has overflowed its stack

In os level this safe but the problem in bare metal can be corrupt the stack an attacker can exploit this.

My rust version

PS E:\Programming\Rust\testrust> rustc --version --verbose
rustc 1.91.0 (f8297e351 2025-10-28)
binary: rustc
commit-hash: f8297e351a40c1439a467bbbb6879088047f50b3
commit-date: 2025-10-28
host: x86_64-pc-windows-msvc
release: 1.91.0
LLVM version: 21.1.2
PS E:\Programming\Rust\testrust\src> 

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.L-false-negativeLint: False negative (should have fired but didn't).L-unconditional_recursionLint: unconditional_recursionneeds-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions