I've just been bitten by a strange segfault, which turned out to be due to insufficient stack space with -Ofast (running nf from the Polyhedron benchmarks). We really need a sensible error message when that happens. "Insufficient stack space, aborting\n" would already be enough. Of course, not every segmentation violation is a stack overflow :-| So, a strategy could be: On startup, prepare a heap buffer with a sensible error message. Also, stash away the starting address of the stack, its size and other pertinent information, and set up a signal handler for SIGSEGV using sigalstack(). On receiving a SIGSEGV, we could check if the segfaulting address is indeed near the end of the stack, and if that is the case, just do a write(2,...) with our prepared error message and exit. Otherwise, just do the normal thing (usually, abort). We could also increase the stack size, to avoid hitting that particular error too soon. What do people think?
Did you try if -fstack-clash-protection provides a better failure mode? It might be required to reliably detect that "end of the stack" case.
(In reply to Richard Biener from comment #1) > Did you try if -fstack-clash-protection provides a better failure mode? It > might be required to reliably detect that "end of the stack" case. No, just a SIGSEGV.
We could look at https://www.gnu.org/software/libsigsegv/ how to do this, or maybe even include this as a prerequisite for libgfortran. Haven't looked in detail yet...
The nf failure is a regression in itself, so we should mark it as such, and we should definitely try to fix this before gcc 10 comes out.
Is https://gcc.gnu.org/viewcvs?rev=274264&root=gcc&view=rev the culprit? And if so, should be reduce it back to the previous default of 32 kB? (A bummer, I had hoped to eventually make -frecursive the default..)
For the case where you want some kind of recovery, -fstack-check is a better approach than -fstack-clash-protection as -fstack-check ensures there's always a page available to the segfault handler.
GCC 10.1 has been released.
I don't see that.
GCC 10.2 is released, adjusting target milestone.
GCC 10.3 is being released, retargeting bugs to GCC 10.4.
GCC 10.4 is being released, retargeting bugs to GCC 10.5.
GCC 10 branch is being closed.