Skip to content

[3.14] GH-130397: remove special-casing of C stack depth for WASI (GH-134469) #134547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions Include/pythonrun.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ PyAPI_DATA(int) (*PyOS_InputHook)(void);
# define PYOS_LOG2_STACK_MARGIN 12
#elif defined(Py_DEBUG) && defined(WIN32)
# 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
# define PYOS_LOG2_STACK_MARGIN 11
#endif
Expand Down
3 changes: 3 additions & 0 deletions Lib/test/test_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ def test_deepcopy_list(self):
self.assertIsNot(x[0], y[0])

@support.skip_emscripten_stack_overflow()
@support.skip_wasi_stack_overflow()
def test_deepcopy_reflexive_list(self):
x = []
x.append(x)
Expand Down Expand Up @@ -400,6 +401,7 @@ def test_deepcopy_tuple_of_immutables(self):
self.assertIs(x, y)

@support.skip_emscripten_stack_overflow()
@support.skip_wasi_stack_overflow()
def test_deepcopy_reflexive_tuple(self):
x = ([],)
x[0].append(x)
Expand All @@ -418,6 +420,7 @@ def test_deepcopy_dict(self):
self.assertIsNot(x["foo"], y["foo"])

@support.skip_emscripten_stack_overflow()
@support.skip_wasi_stack_overflow()
def test_deepcopy_reflexive_dict(self):
x = {}
x['foo'] = x
Expand Down
2 changes: 2 additions & 0 deletions Lib/test/test_descr.py
Original file line number Diff line number Diff line change
Expand Up @@ -3943,6 +3943,7 @@ def __del__(self):
del C.__del__

@unittest.skipIf(support.is_emscripten, "Seems to works in Pyodide?")
@support.skip_wasi_stack_overflow()
def test_slots_trash(self):
# Testing slot trash...
# Deallocating deeply nested slotted trash caused stack overflows
Expand Down Expand Up @@ -4868,6 +4869,7 @@ class Thing:
deque.append(thing, thing)

@support.skip_emscripten_stack_overflow()
@support.skip_wasi_stack_overflow()
def test_repr_as_str(self):
# Issue #11603: crash or infinite loop when rebinding __str__ as
# __repr__.
Expand Down
4 changes: 3 additions & 1 deletion Lib/test/test_exception_group.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import collections.abc
import types
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):
def test_exception_group_types(self):
Expand Down Expand Up @@ -465,12 +465,14 @@ def make_deep_eg(self):
return e

@skip_emscripten_stack_overflow()
@skip_wasi_stack_overflow()
def test_deep_split(self):
e = self.make_deep_eg()
with self.assertRaises(RecursionError):
e.split(TypeError)

@skip_emscripten_stack_overflow()
@skip_wasi_stack_overflow()
def test_deep_subgroup(self):
e = self.make_deep_eg()
with self.assertRaises(RecursionError):
Expand Down
2 changes: 2 additions & 0 deletions Lib/test/test_isinstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ def __bases__(self):
self.assertRaises(RecursionError, isinstance, 1, X())

@support.skip_emscripten_stack_overflow()
@support.skip_wasi_stack_overflow()
def test_infinite_recursion_via_bases_tuple(self):
"""Regression test for bpo-30570."""
class Failure(object):
Expand All @@ -328,6 +329,7 @@ def __getattr__(self, attr):
issubclass(Failure(), int)

@support.skip_emscripten_stack_overflow()
@support.skip_wasi_stack_overflow()
def test_infinite_cycle_in_bases(self):
"""Regression test for bpo-30570."""
class X:
Expand Down
2 changes: 2 additions & 0 deletions Lib/test/test_json/test_recursion.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def default(self, o):


@support.skip_emscripten_stack_overflow()
@support.skip_wasi_stack_overflow()
def test_highly_nested_objects_decoding(self):
very_deep = 200000
# test that loading highly-nested objects doesn't segfault when C
Expand Down Expand Up @@ -98,6 +99,7 @@ def test_highly_nested_objects_encoding(self):
self.dumps(d)

@support.skip_emscripten_stack_overflow()
@support.skip_wasi_stack_overflow()
def test_endless_recursion(self):
# See #12051
class EndlessJSONEncoder(self.json.JSONEncoder):
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
3 changes: 0 additions & 3 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,6 @@ _Py_EnterRecursiveCallUnchecked(PyThreadState *tstate)
# define Py_C_STACK_SIZE 1200000
#elif defined(__sparc__)
# 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__)
# define Py_C_STACK_SIZE 2000000
#else
Expand Down
Loading