New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
faulthandler._stack_overflow doesn't work on x86-linux with KPTI enabled #81037
Comments
In faulthandler.c STACK_OVERFLOW_MAX_SIZE is defined to 100 * 1024 * 1024 (100MB). But recently KPTI has been applied to mitigate Meltdown (CVE-2017-5754) so the userspace stack pointer may be very close to 0xffffffff on Linux systems with 32-bit x86. For example, on my laptop it's sometimes 0xffffcc20. So the expression sp + STACK_OVERFLOW_MAX_SIZE overflows and becomes a very small number. That causes faulthandler._stack_overflow() to bail out after only one recursive call: Traceback (most recent call last):
File "<string>", line 1, in <module>
RuntimeError: unable to raise a stack overflow (allocated 4124 bytes on the stack, 1 recursive calls) |
Are uintptr_t overflow/underflow semantics a defined behavior? |
Yes. Unlike signed overflow, unsigned overflow is defined to be 2's complement. The problem is this overflow results a wrong stack pointer limit and breaks _stack_overflow. |
Thanks Xi Ruoyao, I applied your fix to 3.7 and master branches. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: