Skip to content

Py_C_STACK_SIZE causes test_max_level failure on musl/s390xΒ #139467

@lotheac

Description

@lotheac

Bug report

Bug description:

Hello,

I am updating Python in Alpine to 3.14 and encountered the following test failure on s390x:

======================================================================
ERROR: test_max_level (test.test_grammar.TokenTests.test_max_level)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builds/lotheac/aports/main/python3/src/Python-3.14.0rc3/Lib/test/test_grammar.py", line 257, in test_max_level
    result = eval("(" * MAXLEVEL + ")" * MAXLEVEL)
MemoryError: Parser stack overflowed - Python source too complex to parse

----------------------------------------------------------------------

the root cause seems to be the following define in Python/ceval.c, added in commit 0142236:

#if defined(__s390x__)
#  define Py_C_STACK_SIZE 320000

I was able to make the tests pass by removing this stack size limitation for s390x with the following patch, making it use the default size 4000000 as other architectures do:

diff --git a/Python/ceval.c b/Python/ceval.c
index e5b1b82e45e..fe8c4a7d092 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -352,7 +352,7 @@ _Py_EnterRecursiveCallUnchecked(PyThreadState *tstate)
     }
 }

-#if defined(__s390x__)
+#if 0
 #  define Py_C_STACK_SIZE 320000
 #elif defined(_WIN32)
    // Don't define Py_C_STACK_SIZE, ask the O/S

Because this dumb patch appears to work, I would like to ask you for some insight on why this Py_C_STACK_SIZE override on s390x exists. I'm not very familiar with s390x myself.

CPython versions tested on:

3.14

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.14bugs and security fixes3.15new features, bugs and security fixesOS-unsupportedinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions