Skip to content

Conversation

@Thyre
Copy link
Contributor

@Thyre Thyre commented Jan 9, 2026

Avoid tests being killed due to OOM on Linux if a system is configured with ulimit -s unlimited by skipping tests relying on infinite recursion via infinite_recursion with a high passed number.

While unclear if Python should support ulimit -s unlimited, we should at least try to avoid failing a PGO build running tests due to an unlimited stack size being set.


Note: While this lets make pass on the systems I've tested on (with PGO enabled), make test will fail with ulimit -s unlimited.
On a system with sufficient amount of memory, I saw several of these errors:

Traceback (most recent call last):
  File "/dev/shm/reuter1/jupiter/Python/3.14.2/GCCcore-15.2.0/Python-3.14.2/Lib/test/test_dictviews.py", line 286, in test_deeply_nested_repr
    self.assertRaises(RecursionError, repr, d)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: RecursionError not raised by repr

whereas on my personal machine, I saw some tests with typical recursion (not using infinite_recursion) still filling up the memory due to the machine having substantially less RAM. There were also two or three timeouts, but without triggering OOM.

Based on #143460 (comment), I'd consider this acceptable, but I can also do another round of going through the tests to exclude any test that could yield issues with ulimit -s unlimited.

Avoid tests being killed due to OOM on Linux if a system is configured with
'ulimit -s unlimited' by skipping tests relying on infinite recursion.

While unclear if Python should support 'ulimit -s unlimited', we should at
least try to avoid failing a PGO build running tests due to an unlimited
stack size being set.

Signed-off-by: Jan André Reuter <j.reuter@fz-juelich.de>
@python-cla-bot
Copy link

python-cla-bot bot commented Jan 9, 2026

All commit authors signed the Contributor License Agreement.

CLA signed

Thyre added 2 commits January 9, 2026 14:25
Signed-off-by: Jan André Reuter <j.reuter@fz-juelich.de>
Signed-off-by: Jan André Reuter <j.reuter@fz-juelich.de>
Signed-off-by: Jan André Reuter <j.reuter@fz-juelich.de>
Copy link
Member

@Fidget-Spinner Fidget-Spinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM. Thanks!

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Signed-off-by: Jan André Reuter <j.reuter@fz-juelich.de>
@Fidget-Spinner Fidget-Spinner added the needs backport to 3.14 bugs and security fixes label Jan 9, 2026
@Fidget-Spinner Fidget-Spinner merged commit 61e0366 into python:main Jan 9, 2026
48 checks passed
@miss-islington-app
Copy link

Thanks @Thyre for the PR, and @Fidget-Spinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 9, 2026
…pythonGH-143606)

Avoid tests being killed due to OOM on Linux if a system is configured with
'ulimit -s unlimited' by skipping tests relying on infinite recursion.

While unclear if Python should support 'ulimit -s unlimited', we should at
least try to avoid failing a PGO build running tests due to an unlimited
stack size being set.
(cherry picked from commit 61e0366)

Co-authored-by: Jan André Reuter <jan.andre.reuter@hotmail.de>
Signed-off-by: Jan André Reuter <j.reuter@fz-juelich.de>
@bedevere-app
Copy link

bedevere-app bot commented Jan 9, 2026

GH-143619 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Jan 9, 2026
Fidget-Spinner pushed a commit that referenced this pull request Jan 9, 2026
GH-143606) (#143619)

gh-143460: Skip infinite recusion tests for infinite stack size (GH-143606)

Avoid tests being killed due to OOM on Linux if a system is configured with
'ulimit -s unlimited' by skipping tests relying on infinite recursion.

While unclear if Python should support 'ulimit -s unlimited', we should at
least try to avoid failing a PGO build running tests due to an unlimited
stack size being set.
(cherry picked from commit 61e0366)

Signed-off-by: Jan André Reuter <j.reuter@fz-juelich.de>
Co-authored-by: Jan André Reuter <jan.andre.reuter@hotmail.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants