Skip to content

Unit test test_incremental_gc_handles_fast_cycle_creation sometimes fails #133532

Closed

Description

@nascheme

Bug report

Bug description:

On a debug build on Linux AMD64, this fails for me:

./python -m test -uall test___all__ test_atexit test_audit test_ast test_argparse test_gc
[...]
test test_gc failed -- Traceback (most recent call last):
  File "/home/nas/src/cpython/Lib/contextlib.py", line 85, in inner
    return func(*args, **kwds)
  File "/home/nas/src/cpython/Lib/test/test_gc.py", line 1184, in test_incremental_gc_handles_fast_cycle_creation
    self.assertLess(new_objects, 27_000, f"Heap growing. Reached limit after {i} iterations")
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 27013 not less than 27000 : Heap growing. Reached limit after 6579 iterations

The exact set of tests required before test_gc seems to depend on other factors. More reliable command might be:

./python -m test -uall test___all__ test_buffer test_atexit test_audit test_bigaddrspace test_bdb test_abc test_bufio test_ast test_base64 test_annotationlib test_baseexception test__colorize test__interpreters test_asyncgen test_augassign test_bigmem test_binascii test_bz2 test_abstract_numbers test__osx_support test_c_locale_coercion test_bool test_argparse test_gc

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Activity

  1. added a commit that references this issue on May 6, 2025
  2. nascheme commented on May 6, 2025

    @nascheme
    MemberAuthor

    There seems to be some non-linear behavior happening. Creating a few thousand extra container objects (I used empty lists) before running the test results in the following.

    Initial objects Max new
    23,576 17,199
    33,452 22,407
    43,452 26,418
    63,452 32,592
    103,452 39,606
    183,452 46,998
    343,452 53,235

    A log curve seems to fit the data pretty closely.

    Image

  3. markshannon commented on May 7, 2025

    @markshannon
    Member

    The larger the heap, the longer it takes to scan it, so there's more lag in collecting cycles. That's my guess.

  4. added a commit that references this issue on May 7, 2025
  5. added a commit that references this issue on May 8, 2025
  6. added 2 commits that reference this issue on May 8, 2025
  7. added a commit that references this issue on May 8, 2025
  8. added a commit that references this issue on May 9, 2025
  9. added a commit that references this issue on Jul 12, 2025
  10. nascheme commented on Jul 14, 2025

    @nascheme
    MemberAuthor

    The GH-133533 change has resolved this issue.

  11. added a commit that references this issue on Aug 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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