mirror of
https://github.com/python/cpython.git
synced 2025-10-25 18:54:53 +00:00
GH-130396: Use computed stack limits on linux (GH-130398)
* 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
This commit is contained in:
parent
99088ab081
commit
014223649c
58 changed files with 1295 additions and 1482 deletions
|
|
@ -70,23 +70,25 @@ def default(self, o):
|
|||
|
||||
@support.skip_emscripten_stack_overflow()
|
||||
def test_highly_nested_objects_decoding(self):
|
||||
very_deep = 200000
|
||||
# test that loading highly-nested objects doesn't segfault when C
|
||||
# accelerations are used. See #12017
|
||||
with self.assertRaises(RecursionError):
|
||||
with support.infinite_recursion():
|
||||
self.loads('{"a":' * 100000 + '1' + '}' * 100000)
|
||||
self.loads('{"a":' * very_deep + '1' + '}' * very_deep)
|
||||
with self.assertRaises(RecursionError):
|
||||
with support.infinite_recursion():
|
||||
self.loads('{"a":' * 100000 + '[1]' + '}' * 100000)
|
||||
self.loads('{"a":' * very_deep + '[1]' + '}' * very_deep)
|
||||
with self.assertRaises(RecursionError):
|
||||
with support.infinite_recursion():
|
||||
self.loads('[' * 100000 + '1' + ']' * 100000)
|
||||
self.loads('[' * very_deep + '1' + ']' * very_deep)
|
||||
|
||||
@support.skip_wasi_stack_overflow()
|
||||
@support.skip_emscripten_stack_overflow()
|
||||
def test_highly_nested_objects_encoding(self):
|
||||
# See #12051
|
||||
l, d = [], {}
|
||||
for x in range(100000):
|
||||
for x in range(200_000):
|
||||
l, d = [l], {'k':d}
|
||||
with self.assertRaises(RecursionError):
|
||||
with support.infinite_recursion(5000):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue