Skip to content

Rust code segfaults with stack overflow #79935

@Volker-Weissmann

Description

@Volker-Weissmann

If I'm not mistaken, writing an infinite recursing function, is guaranteed to produce this message:

thread '' has overflowed its stack
fatal runtime error: stack overflow

I recently accidentally wrote an infinite recursing function (src/ir/item.rs:982) and I got this message instead:

process didn't exit successfully: `/home/volker/rust-bindgen/target/debug/deps/tests-ec5d637d33ad84bf stack_overflow` (signal: 11, SIGSEGV: invalid memory reference)

To be fair, rust_bindgen does contain unsafe code, but I still suspect that this SIGSEGV is a bug in rust's handling with segmentation fault, because the call stack of the crash looks like this:

Standard library
Functions that do not contain unsafe code
A few thousand times the `is_constified_enum_module` function
Functions that contain unsafe code
start

How to reproduce:

$ git clone https://github.com/Volker-Weissmann/rust-bindgen --branch stack_overflow --depth 1
$ cd rust-bindgen
$ cargo test stack_overflow

I'm using rustc 1.50.0-nightly (d32c320 2020-12-10)

Note: There is also a forum post about this:
https://users.rust-lang.org/t/is-rust-guaranteed-to-detect-stack-overflows/52593/12

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsC-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions