Skip to content

skip_if_huge_c_stack underestimates available C recursion depth #155109

Description

@kulikjak

Bug report

Bug description:

Hi! With the recent merge of #154277, we started seeing test_parameters_deep_recursion failure on Solaris; and I believe that the reason for this failure is an insufficient heuristic in the skip_if_huge_c_stack decorator.

On Solaris, we run the tests with 16 MiB stacks (rather than widely used 8MiB). At this stack size, the test fails with:

 ======================================================================
 FAIL: test_parameters_deep_recursion (test.test_typing.GenericTests.test_parameters_deep_recursion)
 ----------------------------------------------------------------------
 Traceback (most recent call last):
   File "..../Lib/test/test_typing.py", line 4939, in test_parameters_deep_recursion
     with self.assertRaisesRegex(RecursionError, "in __parameter__ calculation"):
          ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 AssertionError: RecursionError not raised

From my testing, 14 MiB and above causes the failure on Intel, and 32 MiB and above on SPARC (different frame sizes result in different thresholds).

I used a GitHub action with ubuntu-24.04 os to test this on Linux, and it fails there as well at 20MiB+.

BTW, on MacOS, it always passes - either the heuristic works good there, or the stack handling works differently than on other platforms where I tested it (I did not investigate that further).

CPython versions tested on:

CPython main branch

Operating systems tested on:

Other

Linked PRs

Metadata

Metadata

Labels

testsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions