python / python/cpython

Incremental GC does not collect garbage as soon as expected

Open
#142,002 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

3.14 3.15 interpreter-core performance type-bug
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Bug report

Bug description:

This was found by @Yhg1s . If you run tests with this command:

./python -m test --randseed=3169227856 --no-randomize --single-process test_pyclbr test_trace test_pdb test_iter test_ordered_dict test_urllib2_localnet test_array test_generated_cases test_typing test_fnmatch test_tools test_descr test___all__ test_xml_dom_xmlbuilder test_nturl2path test_hmac test_pickle test_android test_ipaddress test_modulefinder test_interpreters test_zoneinfo test_runpy test_sqlite3 test_bdb test_zipfile test_crossinterp test_pulldom test_pkgutil test_re test_dbm_sqlite3 test_venv test_pyrepl test_xml_etree_c test_gc

The test_gc unit test fails with:

  File "/home/thomas/python/python/main/Lib/contextlib.py", line 85, in inner
    return func(*args, **kwds)
  File "/home/thomas/python/python/main/Lib/test/test_gc.py", line 1573, in test_bug1055820d
    self.fail("gc didn't happen after 50000 iterations")
    ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: gc didn't happen after 50000 iterations

Reverting GH-140262 seems to fix this. It is possible this is related to GH-141890 as well.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs
  • gh-142001

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with test/test_gc.py, especially test_bug1055820d, and reproduce the failure using the command in the report. Compare the behavior with GH-140262 reverted and investigate the possible relationship to GH-141890. Done means the test no longer reports that garbage collection failed after 50,000 iterations.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.