Author: Armin Rigo <[email protected]>
Branch:
Changeset: r97861:da8096b43023
Date: 2019-10-25 14:34 +0200
http://bitbucket.org/pypy/pypy/changeset/da8096b43023/
Log: Issue #3094
Simple workaround for programs calling
'sys.setrecursionlimit(huge_value)'
diff --git a/pypy/module/sys/vm.py b/pypy/module/sys/vm.py
--- a/pypy/module/sys/vm.py
+++ b/pypy/module/sys/vm.py
@@ -59,6 +59,12 @@
from rpython.rlib.rgc import increase_root_stack_depth
if new_limit <= 0:
raise oefmt(space.w_ValueError, "recursion limit must be positive")
+ # Some programs use very large values to mean "don't check, I want to
+ # use as much as possible and then segfault". Add a silent upper bound
+ # of 10**6 here, because huge values cause huge shadowstacks to be
+ # allocated (or MemoryErrors).
+ if new_limit > 1000000:
+ new_limit = 1000000
space.sys.recursionlimit = new_limit
_stack_set_length_fraction(new_limit * 0.001)
increase_root_stack_depth(int(new_limit * 0.001 * 163840))
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit