Skip to content

Stack overflow in thread local's drop rendered as a segmentation fault. #109785

Closed as not planned
@jswrenn

Description

@jswrenn

Code

pub fn main() {
    struct RecursiveDrop;

    impl Drop for RecursiveDrop {
        fn drop(&mut self) {
            let _ = RecursiveDrop;
        }
    }

    thread_local!(static LOCAL: RecursiveDrop = const { RecursiveDrop });

    LOCAL.with(|_| {});
}

Current output

Segmentation fault (core dumped)

Desired output

thread 'main' has overflowed its stack
fatal runtime error: stack overflow
Aborted (core dumped)

Rationale and extra context

This should encounter a guard page and produce the expected diagnostic, but it does not.

rustc --version --verbose:

rustc 1.70.0-nightly (44f518058 2023-03-20)
binary: rustc
commit-hash: 44f5180584404d18058cbbf224c55255db4fdcbb
commit-date: 2023-03-20
host: x86_64-unknown-linux-gnu
release: 1.70.0-nightly
LLVM version: 15.0.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsT-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