Skip to content
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

Implement stack overflow protection for linux based on actual stack depth #130396

Open
markshannon opened this issue Feb 21, 2025 · 1 comment
Open
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) OS-linux type-feature A feature request or enhancement

Comments

@markshannon
Copy link
Member

markshannon commented Feb 21, 2025

Linux doesn't offer an API for determining the current stack bounds, at least not that I am aware of.

This means we will need to probe the stack using a SIGSEGV handler and longjmp/setjump.
It is somewhat ugly but should work.

Actually, it looks like pthread_get_stackaddr_np might work, and avoid all the complexity of the signal handler. In theory, it should work for MacOS as well.

Linked PRs

@tomasr8 tomasr8 added interpreter-core (Objects, Python, Grammar, and Parser dirs) OS-linux labels Feb 21, 2025
@picnixz picnixz added the type-feature A feature request or enhancement label Feb 21, 2025
markshannon added a commit that referenced this issue Feb 25, 2025
* Implement C recursion protection with limit pointers for Linux, MacOS and Windows

* Remove calls to PyOS_CheckStack

* Add stack protection to parser

* Make tests more robust to low stacks

* Improve error messages for stack overflow
@encukou
Copy link
Member

encukou commented Feb 25, 2025

This broke two buildbots (both can be seen in the pre-merge run):

Do you have any leads on these issues?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) OS-linux type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

4 participants