Repository navigation
gh-159288: Avoid segfault by adding missing recursion checks when walking lazy import chains - #159289
Conversation
`lazy import a.b.c as d` nests one placeholder per name component. lazy_import_path() and lazy_import_replay_from() recursed over that chain without a recursion check, so a very long dotted name could overflow the C stack. Raise RecursionError instead, as the rest of lazy import resolution does.
|
FYI, the Android test failure should be fixed by either one of the PRs attached to #159320... |
|
Thanks @brittanyrey for the PR, and @Yhg1s for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15. |
|
GH-159416 is a backport of this pull request to the 3.15 branch. |
…hen walking lazy import chains (GH-159289) (#159416) gh-159288: Avoid segfault by adding missing recursion checks when walking lazy import chains (GH-159289) Add missing recursion checks when walking lazy import chains `lazy import a.b.c as d` nests one placeholder per name component. lazy_import_path() and lazy_import_replay_from() recursed over that chain without a recursion check, so a very long dotted name could overflow the C stack. Raise RecursionError instead, as the rest of lazy import resolution does. (cherry picked from commit 2588362) Co-authored-by: Brittany Reynoso <breynoso@meta.com>
|
|
|
|
The Alpine buildbot failures on main would be fixed by #159376 (which could use a review ;p), but I don't really want to backport that one to 3.15. The fixed recursion limit on Alpine (actually, non-glibc) Linux has been an issue for a while and I don't want to inadvertently break some place where pthread_getattr_np does the wrong thing and we haven't discovered it yet. So, we probably need a separate fix for the 3.15 backport of this PR to skip the test on musl (using |
lazy import a.b.c as dnests one placeholder per name component.lazy_import_path()andlazy_import_replay_from()recursed over that chain without a recursion check, so a very long dotted name could overflow the stack.Add guards to raise a
RecursionErrorinstead of failing into a segfault.