You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have 100% safe code that segfaults, presumably due to stack exhaustion.
Exhausting stack space in a simple Rust program triggers telltale error messages (thread 'foo' has overflowed its stack, fatal runtime error: stack overflow) and death via SIGABRT. In the behavior I have encountered, these messages are not printed, and the process is killed with SIGSEGV.
It is my understanding that a crate consisting of 100% safe Rust (even if it has bugs) should not segfault like this. I would expect an explicit stack exhaustion error and death by SIGABRT. When examining this in gdb, I see a large number of stack frames (over 40,000) due to the erroneous fmt::Display implementation. In the bottom frame, there is a clear null pointer dereference (call to a method where &self has address 0).
Perhaps that unsafe block is a red herring, and this is really just a case of things behaving poorly when stack space is exhausted. (Cf. discussion at https://sunshowers.io/posts/rustc-segfault-illumos/.) If this is the case, is there a bug in how stack exhaustion is being handled?
The text was updated successfully, but these errors were encountered:
If I set LIBCLANG_DISABLE_CRASH_RECOVERY=yes, then I do see the thread 'main' has overflowed its stack fatal runtime error: stack overflow message printed from Rust's SIGSEGV handler.
saethlin
added
C-discussion
Category: Discussion or questions that doesn't represent real issues.
and removed
C-bug
Category: This is a bug.
needs-triage
This issue may need triage. Remove it if it has been sufficiently triaged.
labels
Apr 10, 2025
I have 100% safe code that segfaults, presumably due to stack exhaustion.
Exhausting stack space in a simple Rust program triggers telltale error messages (
thread 'foo' has overflowed its stack
,fatal runtime error: stack overflow
) and death via SIGABRT. In the behavior I have encountered, these messages are not printed, and the process is killed with SIGSEGV.It is my understanding that a crate consisting of 100% safe Rust (even if it has bugs) should not segfault like this. I would expect an explicit stack exhaustion error and death by SIGABRT. When examining this in gdb, I see a large number of stack frames (over 40,000) due to the erroneous fmt::Display implementation. In the bottom frame, there is a clear null pointer dereference (call to a method where
&self
has address 0).Example code can be found at https://git.sdf.org/vitrine/shatterc/src/branch/reproduce-segfault. You can reproduce this with these steps:
reproduce-segfault
branchcargo run -- example-cycle.c
Two thoughts about where to look next:
formatter
is invoked. Perhaps this is related to CFI: core and std have explict CFI violations #115199.The text was updated successfully, but these errors were encountered: