GCC Newspaper
NOVEMBER 30, 2026
gcc — Proposed — Sentiment 7 / 10

Fixing -fsplit-stack issues

Proposes fixes for severe issues in GCC's -fsplit-stack option, aiming to improve performance and stability for recursion-heavy code.

Thomas Neumann proposes to fix critical issues with GCC’s -fsplit-stack option that hinder its practical use. The main problems identified are high stack switch overhead (167ns due to signal blocking), incorrect stack computation for signal handlers leading to crashes on AVX-512 systems, and crashes during exception unwinding. Prototype fixes are available for x86-64, aiming to reduce switch costs to around 5ns by making __morestack re-entrant safe.

In the Thread 3 participants
  1. Thomas Neumann <tneumann@users.sourceforge.net> proposer

    Identifies and proposes fixes for three main issues in -fsplit-stack: high stack switch cost, incorrect signal handler stack computation, and crashes during exception unwinding.

    “I have prototype fixes for all three (x86-64 only for now). By making __morestack re-entrant safe we can avoid signal blocking, bringing stack switch cost to about 5ns, which fixes the hot loop problem. The other two are largely classical bug fixes.”
  2. Martin Uecker <uecker@tugraz.at> other

    Acknowledges the description of issues with -fsplit-stack.

  3. Ian Lance Taylor <ian@airs.com> other

    Acknowledges the description of issues with -fsplit-stack.

Technical Tradeoffs

  • Potential for increased complexity in signal handling and exception unwinding code to achieve performance gains.
  • The fixes are currently x86-64 specific, requiring further work for other architectures.

In Details

This thread addresses problems in GCC's -fsplit-stack compiler option, which enables recursive functions to use a dynamically growing stack. The issues concern performance (high cost of stack switching due to signal blocking), correctness (crashes in signal handlers on AVX-512, and during exception unwinding), and potentially alloca/VLA usage. The proposer has developed fixes for x86-64 that target __morestack re-entrancy to reduce overhead.

For Context
-fsplit-stack
A GCC compiler option that modifies function prologue/epilogue to handle stack overflow dynamically by allocating more stack space when needed. This is particularly useful for deeply recursive functions.
AVX-512
Advanced Vector Extensions 512, an instruction set extension for Intel processors that allows for wider vector operations.
re-entrant
A function that can be interrupted in the middle of its execution, safely called again (re-entered) before the previous invocation completes, and then continue correctly. This is crucial for signal handlers and multi-threaded environments.
alloca
A function that allocates memory on the call stack. The memory is automatically freed when the calling function returns.
VLA
Variable Length Array. An array whose size is determined at runtime rather than compile time.
Filed Under: gcc-fsplit-stackstack overflowrecursionperformance