mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
GH-130397: remove special-casing of C stack depth for WASI (#134469)
Removed special-casing for WASI when setting C stack depth limits. Since WASI has its own C stack checking this isn't a security risk. Also disabled some tests that stopped passing. They all happened to have already been disabled under Emscripten.
This commit is contained in:
parent
742d5b5c5d
commit
ad42dc1909
8 changed files with 15 additions and 7 deletions
|
@ -29,9 +29,6 @@ PyAPI_DATA(int) (*PyOS_InputHook)(void);
|
||||||
# define PYOS_LOG2_STACK_MARGIN 12
|
# define PYOS_LOG2_STACK_MARGIN 12
|
||||||
#elif defined(Py_DEBUG) && defined(WIN32)
|
#elif defined(Py_DEBUG) && defined(WIN32)
|
||||||
# define PYOS_LOG2_STACK_MARGIN 12
|
# define PYOS_LOG2_STACK_MARGIN 12
|
||||||
#elif defined(__wasi__)
|
|
||||||
/* Web assembly has two stacks, so this isn't really a size */
|
|
||||||
# define PYOS_LOG2_STACK_MARGIN 9
|
|
||||||
#else
|
#else
|
||||||
# define PYOS_LOG2_STACK_MARGIN 11
|
# define PYOS_LOG2_STACK_MARGIN 11
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -372,6 +372,7 @@ class TestCopy(unittest.TestCase):
|
||||||
self.assertIsNot(x[0], y[0])
|
self.assertIsNot(x[0], y[0])
|
||||||
|
|
||||||
@support.skip_emscripten_stack_overflow()
|
@support.skip_emscripten_stack_overflow()
|
||||||
|
@support.skip_wasi_stack_overflow()
|
||||||
def test_deepcopy_reflexive_list(self):
|
def test_deepcopy_reflexive_list(self):
|
||||||
x = []
|
x = []
|
||||||
x.append(x)
|
x.append(x)
|
||||||
|
@ -400,6 +401,7 @@ class TestCopy(unittest.TestCase):
|
||||||
self.assertIs(x, y)
|
self.assertIs(x, y)
|
||||||
|
|
||||||
@support.skip_emscripten_stack_overflow()
|
@support.skip_emscripten_stack_overflow()
|
||||||
|
@support.skip_wasi_stack_overflow()
|
||||||
def test_deepcopy_reflexive_tuple(self):
|
def test_deepcopy_reflexive_tuple(self):
|
||||||
x = ([],)
|
x = ([],)
|
||||||
x[0].append(x)
|
x[0].append(x)
|
||||||
|
@ -418,6 +420,7 @@ class TestCopy(unittest.TestCase):
|
||||||
self.assertIsNot(x["foo"], y["foo"])
|
self.assertIsNot(x["foo"], y["foo"])
|
||||||
|
|
||||||
@support.skip_emscripten_stack_overflow()
|
@support.skip_emscripten_stack_overflow()
|
||||||
|
@support.skip_wasi_stack_overflow()
|
||||||
def test_deepcopy_reflexive_dict(self):
|
def test_deepcopy_reflexive_dict(self):
|
||||||
x = {}
|
x = {}
|
||||||
x['foo'] = x
|
x['foo'] = x
|
||||||
|
|
|
@ -3943,6 +3943,7 @@ class ClassPropertiesAndMethods(unittest.TestCase):
|
||||||
del C.__del__
|
del C.__del__
|
||||||
|
|
||||||
@unittest.skipIf(support.is_emscripten, "Seems to works in Pyodide?")
|
@unittest.skipIf(support.is_emscripten, "Seems to works in Pyodide?")
|
||||||
|
@support.skip_wasi_stack_overflow()
|
||||||
def test_slots_trash(self):
|
def test_slots_trash(self):
|
||||||
# Testing slot trash...
|
# Testing slot trash...
|
||||||
# Deallocating deeply nested slotted trash caused stack overflows
|
# Deallocating deeply nested slotted trash caused stack overflows
|
||||||
|
@ -4868,6 +4869,7 @@ class ClassPropertiesAndMethods(unittest.TestCase):
|
||||||
deque.append(thing, thing)
|
deque.append(thing, thing)
|
||||||
|
|
||||||
@support.skip_emscripten_stack_overflow()
|
@support.skip_emscripten_stack_overflow()
|
||||||
|
@support.skip_wasi_stack_overflow()
|
||||||
def test_repr_as_str(self):
|
def test_repr_as_str(self):
|
||||||
# Issue #11603: crash or infinite loop when rebinding __str__ as
|
# Issue #11603: crash or infinite loop when rebinding __str__ as
|
||||||
# __repr__.
|
# __repr__.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import collections.abc
|
import collections.abc
|
||||||
import types
|
import types
|
||||||
import unittest
|
import unittest
|
||||||
from test.support import skip_emscripten_stack_overflow, exceeds_recursion_limit
|
from test.support import skip_emscripten_stack_overflow, skip_wasi_stack_overflow, exceeds_recursion_limit
|
||||||
|
|
||||||
class TestExceptionGroupTypeHierarchy(unittest.TestCase):
|
class TestExceptionGroupTypeHierarchy(unittest.TestCase):
|
||||||
def test_exception_group_types(self):
|
def test_exception_group_types(self):
|
||||||
|
@ -465,12 +465,14 @@ class DeepRecursionInSplitAndSubgroup(unittest.TestCase):
|
||||||
return e
|
return e
|
||||||
|
|
||||||
@skip_emscripten_stack_overflow()
|
@skip_emscripten_stack_overflow()
|
||||||
|
@skip_wasi_stack_overflow()
|
||||||
def test_deep_split(self):
|
def test_deep_split(self):
|
||||||
e = self.make_deep_eg()
|
e = self.make_deep_eg()
|
||||||
with self.assertRaises(RecursionError):
|
with self.assertRaises(RecursionError):
|
||||||
e.split(TypeError)
|
e.split(TypeError)
|
||||||
|
|
||||||
@skip_emscripten_stack_overflow()
|
@skip_emscripten_stack_overflow()
|
||||||
|
@skip_wasi_stack_overflow()
|
||||||
def test_deep_subgroup(self):
|
def test_deep_subgroup(self):
|
||||||
e = self.make_deep_eg()
|
e = self.make_deep_eg()
|
||||||
with self.assertRaises(RecursionError):
|
with self.assertRaises(RecursionError):
|
||||||
|
|
|
@ -318,6 +318,7 @@ class TestIsInstanceIsSubclass(unittest.TestCase):
|
||||||
self.assertRaises(RecursionError, isinstance, 1, X())
|
self.assertRaises(RecursionError, isinstance, 1, X())
|
||||||
|
|
||||||
@support.skip_emscripten_stack_overflow()
|
@support.skip_emscripten_stack_overflow()
|
||||||
|
@support.skip_wasi_stack_overflow()
|
||||||
def test_infinite_recursion_via_bases_tuple(self):
|
def test_infinite_recursion_via_bases_tuple(self):
|
||||||
"""Regression test for bpo-30570."""
|
"""Regression test for bpo-30570."""
|
||||||
class Failure(object):
|
class Failure(object):
|
||||||
|
@ -328,6 +329,7 @@ class TestIsInstanceIsSubclass(unittest.TestCase):
|
||||||
issubclass(Failure(), int)
|
issubclass(Failure(), int)
|
||||||
|
|
||||||
@support.skip_emscripten_stack_overflow()
|
@support.skip_emscripten_stack_overflow()
|
||||||
|
@support.skip_wasi_stack_overflow()
|
||||||
def test_infinite_cycle_in_bases(self):
|
def test_infinite_cycle_in_bases(self):
|
||||||
"""Regression test for bpo-30570."""
|
"""Regression test for bpo-30570."""
|
||||||
class X:
|
class X:
|
||||||
|
|
|
@ -69,6 +69,7 @@ class TestRecursion:
|
||||||
|
|
||||||
|
|
||||||
@support.skip_emscripten_stack_overflow()
|
@support.skip_emscripten_stack_overflow()
|
||||||
|
@support.skip_wasi_stack_overflow()
|
||||||
def test_highly_nested_objects_decoding(self):
|
def test_highly_nested_objects_decoding(self):
|
||||||
very_deep = 200000
|
very_deep = 200000
|
||||||
# test that loading highly-nested objects doesn't segfault when C
|
# test that loading highly-nested objects doesn't segfault when C
|
||||||
|
@ -98,6 +99,7 @@ class TestRecursion:
|
||||||
self.dumps(d)
|
self.dumps(d)
|
||||||
|
|
||||||
@support.skip_emscripten_stack_overflow()
|
@support.skip_emscripten_stack_overflow()
|
||||||
|
@support.skip_wasi_stack_overflow()
|
||||||
def test_endless_recursion(self):
|
def test_endless_recursion(self):
|
||||||
# See #12051
|
# See #12051
|
||||||
class EndlessJSONEncoder(self.json.JSONEncoder):
|
class EndlessJSONEncoder(self.json.JSONEncoder):
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
Remove special-casing for C stack depth limits for WASI. Due to
|
||||||
|
WebAssembly's built-in stack protection this does not pose a security
|
||||||
|
concern.
|
|
@ -360,9 +360,6 @@ _Py_EnterRecursiveCallUnchecked(PyThreadState *tstate)
|
||||||
# define Py_C_STACK_SIZE 1200000
|
# define Py_C_STACK_SIZE 1200000
|
||||||
#elif defined(__sparc__)
|
#elif defined(__sparc__)
|
||||||
# define Py_C_STACK_SIZE 1600000
|
# define Py_C_STACK_SIZE 1600000
|
||||||
#elif defined(__wasi__)
|
|
||||||
/* Web assembly has two stacks, so this isn't really the stack depth */
|
|
||||||
# define Py_C_STACK_SIZE 131072 // wasi-libc DEFAULT_STACK_SIZE
|
|
||||||
#elif defined(__hppa__) || defined(__powerpc64__)
|
#elif defined(__hppa__) || defined(__powerpc64__)
|
||||||
# define Py_C_STACK_SIZE 2000000
|
# define Py_C_STACK_SIZE 2000000
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue