Closed ghost closed 6 years ago
Original comment by Anselm Kruis (Bitbucket: akruis, GitHub: akruis):
I can reproduce the problem.
It is caused by a bug in Stackless/platf/switch_x86_unix.h. It declares the function int slp_switch() as static. The problem is: the ABI specification for i386 does not apply the static functions. Therefore the compile is free to optimize. I fixed the header for i386 and for other UNIX-like architectures with the same problem.
Additionally I recycled the buggy FRHACK to omit the code for saving the frame pointer. The Unix configure compiles slp_transfer.c with -fno-omit-frame-pointer (except on Darwin). Therefore the compiler preserves the frame pointer register by default and there is no need to save it explicitly.
I also changed the optimization flags for slp_transfer.c from the unspecific -O2 to the specific -fno-inline-functions. This way it is clear, what optimization must be avoided.
Unfortunately, I have only i386/amd64 based systems for testing.
Fixed for 2.7-slp by 4f7698499ad5
Originally reported by: David Gervais (Bitbucket: drgervais, GitHub: Unknown)
When compiling 32-bit builds of stackless 2.7.x using gcc versions 4.8.4 and higher on a variant of Ubuntu linux, compiler optimizations lead to segfaults as a result of apparent stack corruption.
Confirmed issues using gcc 4.8.4 and 5.3.1 across the stackless 2.7-slp branch.
Indications are that the issue is specific to the slp_transfer.c functions. I can get all unit tests to pass (i.e. Stackless/unittests/runAll.py) only if I use the attached patch that disables compiler optimizations across slp_transfer.c defined functions. Using anything other than O0 in these functions results in a segfault and similar stacktrace.
The base compiler flags used during my test compilation are:
with config.status snippet:
gdb stack snippet running unittests with 2.7.12-slp and gcc 5.3.1:
compiler_optimization_hack.patch.zip