Skip to content

bpo-46417: Py_Finalize() clears static types - #30743

Merged
vstinner merged 1 commit into
python:mainfrom
vstinner:fini_types
Jan 21, 2022
Merged

vstinner merged 1 commit into
python:mainfrom
vstinner:fini_types

Conversation

@vstinner

@vstinner vstinner commented Jan 21, 2022 •

Copy link
Copy Markdown
Member

Add _PyTypes_FiniTypes(): best-effort function to clear static types,
don't deallocate a type if it still has subclasses.

remove_subclass() now sets tp_subclasses to NULL when removing the
last subclass.

https://bugs.python.org/issue46417

Add _PyTypes_FiniTypes(): best-effort function to clear static types,
don't deallocate a type if it still has subclasses.

remove_subclass() now sets tp_subclasses to NULL when removing the
last subclass.
@vstinner

Copy link
Copy Markdown
Member Author

Using PR #30744, the effect of this PR is quite clear on the total reference count after Py_Finalize():

  • Before (main branch): [10120 refs, 3740 blocks]
  • After (this PR): [4801 refs, 1926 blocks]

This PR removes 5319 references. With the PR, there are 2.1x less references leaked after Py_Finalize()!

@vstinner

Copy link
Copy Markdown
Member Author

_PyTypes_FiniTypes() is tested (indirectly) by multiple test_embed tests which use many of the cleared types after Py_Finalize().

@vstinner
vstinner merged commit 595225e into python:main Jan 21, 2022
@vstinner
vstinner deleted the fini_types branch January 21, 2022 12:06
@bedevere-bot

Copy link
Copy Markdown

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

Hi! The buildbot s390x Debian 3.x has failed when building commit 595225e.

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/all/#builders/49/builds/1789) and take a look at the build logs.
  4. Check if the failure is related to this commit (595225e) 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/all/#builders/49/builds/1789

Failed tests:

  • test_unittest

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

==

Click to see traceback logs
Traceback (most recent call last):
  File "/home/dje/cpython-buildarea/3.x.edelsohn-debian-z/build/Lib/multiprocessing/resource_tracker.py", line 209, in main
    cache[rtype].remove(name)
    ^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: '/psm_b32ae02e'


Traceback (most recent call last):
  File "/home/dje/cpython-buildarea/3.x.edelsohn-debian-z/build/Lib/multiprocessing/resource_tracker.py", line 209, in main
    cache[rtype].remove(name)
    ^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: '/psm_bb4f5e76'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants