Commit 7dd87bd1 authored by Armin Rigo's avatar Armin Rigo
Browse files

Issue #3094

Simple workaround for programs calling 'sys.setrecursionlimit(huge_value)'
parent ce2c72abde3a
......@@ -59,6 +59,12 @@ threads you can configure the limit by calling "threading.stack_size()".
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))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment