Skip to content

GH-133261: Make sure that the GC doesn't untrack objects in trashcan #133431

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 5, 2025

Conversation

markshannon
Copy link
Member

@markshannon markshannon commented May 5, 2025

The trashcan stores pointers in the reference count field. This could make the object appear immortal causing the GC to untrack it.
This PR makes sure that those pointers are stored in such a way as to never appear immortal.

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.

This change can explain a lot of very weird bugs and crashes that I saw last days on buildbots and GitHub CIs.

@vstinner
Copy link
Member

vstinner commented May 5, 2025

Tests / Hypothesis tests on Ubuntu (pull_request)Failing after 7m

test_external_inspection failed:

FAIL: test_async_remote_stack_trace (test.test_external_inspection.TestGetStackTrace.test_async_remote_stack_trace) (task_factory_variant='asyncio.new_event_loop')

I wrote a fix for this one: #133433.

@vstinner
Copy link
Member

vstinner commented May 5, 2025

Without this change, test_frame crash after a few attempts (between 1 and 3).

With this change, test_frame does no longer crash. I ran ./python -u -m test -j2 -F test_frame for 3 minutes:

0:03:46 load avg: 3.06 [211] test_frame passed
0:03:47 load avg: 3.06 [212] test_frame passed
...

@markshannon markshannon merged commit f554237 into python:main May 5, 2025
42 of 43 checks passed
@vstinner
Copy link
Member

vstinner commented May 5, 2025

With this change, #133199 (gh-124715: Fix method_dealloc(): use PyObject_GC_UnTrack()) can also be reverted: test_functools no longer crash.

@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot x86 Debian Non-Debug with X 3.x (no tier) has failed when building commit f554237.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/1245/builds/5317) and take a look at the build logs.
  4. Check if the failure is related to this commit (f554237) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/1245/builds/5317

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (test.test_exceptions.ExceptionTests.testInvalidTraceback) ... �[32mok�[0m


Traceback (most recent call last):
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.nondebug/build/Lib/test/support/__init__.py"�[0m, line �[35m2876�[0m, in �[35mwrapper�[0m
    return func(*args, **kwargs)
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.nondebug/build/Lib/test/test_exceptions.py"�[0m, line �[35m1518�[0m, in �[35mtest_recursion_normalizing_infinite_exception�[0m
    �[31mself.assertEqual�[0m�[1;31m(rc, 1)�[0m
    �[31m~~~~~~~~~~~~~~~~�[0m�[1;31m^^^^^^^�[0m
�[1;35mAssertionError�[0m: �[35m-6 != 1�[0m


Traceback (test.test_exceptions.ExceptionTests.testWithTraceback) ... �[32mok�[0m


TracebackAttr (test.test_exceptions.ExceptionTests.testNoneClearsTracebackAttr) ... �[32mok�[0m

@vstinner
Copy link
Member

vstinner commented May 5, 2025

Hi! The buildbot x86 Debian Non-Debug with X 3.x (no tier) has failed when building commit f554237.

That's not good, many tests failed with Assertion '!_Py_IsImmortal(op)' failed:

13 tests failed:
    test_call test_capi test_ctypes test_descr test_dict
    test_dictviews test_exception_group test_exceptions test_frame
    test_functools test_isinstance test_json test_list

@markshannon
Copy link
Member Author

That's a 32 bit machine, right?
I'll take a look.

@markshannon markshannon deleted the fix-133261 branch May 6, 2025 08:21
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.

3 participants