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.
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.
- fixing -fsplit-stack Thomas Neumann via Gcc
-