Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 15e26ee

Browse filesBrowse files
[3.14] GH-130397: remove special-casing of C stack depth for WASI (GH-134469) (GH-134547)
GH-130397: remove special-casing of C stack depth for WASI (GH-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. (cherry picked from commit ad42dc1) Co-authored-by: Brett Cannon <brett@python.org>
1 parent 06a3a85 commit 15e26ee
Copy full SHA for 15e26ee

File tree

Expand file treeCollapse file tree

8 files changed

+15
-7
lines changed
Filter options
Expand file treeCollapse file tree

8 files changed

+15
-7
lines changed

‎Include/pythonrun.h

Copy file name to clipboardExpand all lines: Include/pythonrun.h
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ PyAPI_DATA(int) (*PyOS_InputHook)(void);
2929
# define PYOS_LOG2_STACK_MARGIN 12
3030
#elif defined(Py_DEBUG) && defined(WIN32)
3131
# define PYOS_LOG2_STACK_MARGIN 12
32-
#elif defined(__wasi__)
33-
/* Web assembly has two stacks, so this isn't really a size */
34-
# define PYOS_LOG2_STACK_MARGIN 9
3532
#else
3633
# define PYOS_LOG2_STACK_MARGIN 11
3734
#endif

‎Lib/test/test_copy.py

Copy file name to clipboardExpand all lines: Lib/test/test_copy.py
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ def test_deepcopy_list(self):
372372
self.assertIsNot(x[0], y[0])
373373

374374
@support.skip_emscripten_stack_overflow()
375+
@support.skip_wasi_stack_overflow()
375376
def test_deepcopy_reflexive_list(self):
376377
x = []
377378
x.append(x)
@@ -400,6 +401,7 @@ def test_deepcopy_tuple_of_immutables(self):
400401
self.assertIs(x, y)
401402

402403
@support.skip_emscripten_stack_overflow()
404+
@support.skip_wasi_stack_overflow()
403405
def test_deepcopy_reflexive_tuple(self):
404406
x = ([],)
405407
x[0].append(x)
@@ -418,6 +420,7 @@ def test_deepcopy_dict(self):
418420
self.assertIsNot(x["foo"], y["foo"])
419421

420422
@support.skip_emscripten_stack_overflow()
423+
@support.skip_wasi_stack_overflow()
421424
def test_deepcopy_reflexive_dict(self):
422425
x = {}
423426
x['foo'] = x

‎Lib/test/test_descr.py

Copy file name to clipboardExpand all lines: Lib/test/test_descr.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3943,6 +3943,7 @@ def __del__(self):
39433943
del C.__del__
39443944

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

48704871
@support.skip_emscripten_stack_overflow()
4872+
@support.skip_wasi_stack_overflow()
48714873
def test_repr_as_str(self):
48724874
# Issue #11603: crash or infinite loop when rebinding __str__ as
48734875
# __repr__.

‎Lib/test/test_exception_group.py

Copy file name to clipboardExpand all lines: Lib/test/test_exception_group.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import collections.abc
22
import types
33
import unittest
4-
from test.support import skip_emscripten_stack_overflow, exceeds_recursion_limit
4+
from test.support import skip_emscripten_stack_overflow, skip_wasi_stack_overflow, exceeds_recursion_limit
55

66
class TestExceptionGroupTypeHierarchy(unittest.TestCase):
77
def test_exception_group_types(self):
@@ -465,12 +465,14 @@ def make_deep_eg(self):
465465
return e
466466

467467
@skip_emscripten_stack_overflow()
468+
@skip_wasi_stack_overflow()
468469
def test_deep_split(self):
469470
e = self.make_deep_eg()
470471
with self.assertRaises(RecursionError):
471472
e.split(TypeError)
472473

473474
@skip_emscripten_stack_overflow()
475+
@skip_wasi_stack_overflow()
474476
def test_deep_subgroup(self):
475477
e = self.make_deep_eg()
476478
with self.assertRaises(RecursionError):

‎Lib/test/test_isinstance.py

Copy file name to clipboardExpand all lines: Lib/test/test_isinstance.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ def __bases__(self):
318318
self.assertRaises(RecursionError, isinstance, 1, X())
319319

320320
@support.skip_emscripten_stack_overflow()
321+
@support.skip_wasi_stack_overflow()
321322
def test_infinite_recursion_via_bases_tuple(self):
322323
"""Regression test for bpo-30570."""
323324
class Failure(object):
@@ -328,6 +329,7 @@ def __getattr__(self, attr):
328329
issubclass(Failure(), int)
329330

330331
@support.skip_emscripten_stack_overflow()
332+
@support.skip_wasi_stack_overflow()
331333
def test_infinite_cycle_in_bases(self):
332334
"""Regression test for bpo-30570."""
333335
class X:

‎Lib/test/test_json/test_recursion.py

Copy file name to clipboardExpand all lines: Lib/test/test_json/test_recursion.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def default(self, o):
6969

7070

7171
@support.skip_emscripten_stack_overflow()
72+
@support.skip_wasi_stack_overflow()
7273
def test_highly_nested_objects_decoding(self):
7374
very_deep = 200000
7475
# test that loading highly-nested objects doesn't segfault when C
@@ -98,6 +99,7 @@ def test_highly_nested_objects_encoding(self):
9899
self.dumps(d)
99100

100101
@support.skip_emscripten_stack_overflow()
102+
@support.skip_wasi_stack_overflow()
101103
def test_endless_recursion(self):
102104
# See #12051
103105
class EndlessJSONEncoder(self.json.JSONEncoder):
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Remove special-casing for C stack depth limits for WASI. Due to
2+
WebAssembly's built-in stack protection this does not pose a security
3+
concern.

‎Python/ceval.c

Copy file name to clipboardExpand all lines: Python/ceval.c
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,6 @@ _Py_EnterRecursiveCallUnchecked(PyThreadState *tstate)
360360
# define Py_C_STACK_SIZE 1200000
361361
#elif defined(__sparc__)
362362
# define Py_C_STACK_SIZE 1600000
363-
#elif defined(__wasi__)
364-
/* Web assembly has two stacks, so this isn't really the stack depth */
365-
# define Py_C_STACK_SIZE 131072 // wasi-libc DEFAULT_STACK_SIZE
366363
#elif defined(__hppa__) || defined(__powerpc64__)
367364
# define Py_C_STACK_SIZE 2000000
368365
#else

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.