fixing -fsplit-stack
Martin Uecker
uecker@tugraz.at
Tue Oct 20 11:33:30 GMT 2026
Am Dienstag, dem 20.10.2026 um 10:58 +0200 schrieb Thomas Neumann via Gcc:
> Hi,
>
> I would like to use -fsplit-stack for some recursion heavy C++ code, but
> I noticed that it currently has severe issues, which prevents practical
> usage, but which are fixable: 1) currently a stack switch costs about
> 167ns due to signal blocking, which is prohibitive in hot loops 2) the
> stack computation for signal handlers is wrong, which leads to crashes
> on machines with AVX-512 support, and 3) a signaler handler with split
> stack causes a crash if the signal happens 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.
>
> Before working on this more, are you actually interested in reviving
> this functionality? I got the impression that the code is hardly used at
> all (except for go, which uses a separate signal stack and thus avoids
> some of these problems). But I think it would be useful to make it work,
> as it makes recursive functions much more practical.
Only speaking for myself and I will not be able to help, but I would
definitely be interested in using this in C and I think others would too.
>
> Thomas
>
> PS: I noticed that alloca/VLA with split stack is broken, too, because
> the memory allocated by __morestack_allocate_stack_space is not freed
> properly. I don't care about this too much, and fixing it requires
> compiler changes, thus I did not try to fix it. But perhaps it should be
> addressed, too.
VLAs would be important for me.
What about longjmp / setjmp?
Martin
More information about the Gcc
mailing list