Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-119127: Fix _functools.Placeholder singleton#124601

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
vstinner merged 1 commit intopython:mainfromvstinner:placeholder
Sep 26, 2024

Conversation

vstinner
Copy link
Member

@vstinnervstinner commentedSep 26, 2024
edited by bedevere-appbot
Loading

  • The module state now stores a strong reference to the Placeholder singleton.
  • Use a regular dealloc function.
  • Add Py_TPFLAGS_HAVE_GC flag and traverse function to help the GC to collect the type when _functools extension is unloaded.

dg-pb, Eclips4, and ZeroIntensity reacted with thumbs up emoji
* The module state now stores a strong reference to the Placeholder  singleton.* Use a regular dealloc function.* Add Py_TPFLAGS_HAVE_GC flag and traverse function to help the GC to  collect the type when _functools extension is unloaded.
@vstinner
Copy link
MemberAuthor

Copy link
Member

@ZeroIntensityZeroIntensity left a comment

Choose a reason for hiding this comment

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

This looks like the right fix. I haven't manually confirmed that this fixes the refleak, but this is the proper way to implement singletons. (Originally, it was just an immortal object that never gets freed, and therefore causes a leak -- it gets worse as new subinterpreters are created and the module is reset.)

Thank you, Victor! Should this be targetinggh-124586 rather thangh-119127?

@vstinner
Copy link
MemberAuthor

Thank you, Victor! Should this be targeting#124586 rather than#119127?

This PR is a follow-up ofgh-119127.

@vstinner
Copy link
MemberAuthor

This looks like the right fix. I haven't manually confirmed that this fixes the refleak

I checked manually that test_ast no longer leaks with this change.

@Eclips4
Copy link
Member

!buildbot refleaks

@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by@Eclips4 for commit37e994a 🤖

The command will test the builders whose names match following regular expression:refleaks

The builders matched are:

  • aarch64 CentOS9 Refleaks PR
  • AMD64 Fedora Rawhide Refleaks PR
  • AMD64 Fedora Rawhide NoGIL refleaks PR
  • aarch64 Fedora Rawhide Refleaks PR
  • AMD64 Windows11 Refleaks PR
  • PPC64LE Fedora Rawhide NoGIL refleaks PR
  • AMD64 Fedora Stable Refleaks PR
  • s390x RHEL8 Refleaks PR
  • aarch64 Fedora Stable Refleaks PR
  • PPC64LE Fedora Stable Refleaks PR
  • PPC64LE RHEL8 Refleaks PR
  • AMD64 RHEL8 Refleaks PR
  • AMD64 CentOS9 NoGIL Refleaks PR
  • AMD64 CentOS9 Refleaks PR
  • ARM64 MacOS M1 Refleaks NoGIL PR
  • s390x Fedora Refleaks PR
  • PPC64LE Fedora Rawhide Refleaks PR
  • aarch64 Fedora Rawhide NoGIL refleaks PR
  • s390x RHEL9 Refleaks PR
  • PPC64LE CentOS9 Refleaks PR
  • s390x Fedora Rawhide Refleaks PR
  • aarch64 RHEL8 Refleaks PR

Copy link
Member

@Eclips4Eclips4 left a comment

Choose a reason for hiding this comment

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

LGTM. I've checked it locally and there's no leak intest_ast with this patch applied.
I run buildbots to make sure that everything is fine.

_Py_SetImmortal(placeholder);
PyObject_GC_UnTrack(self);
PyTypeObject *tp = Py_TYPE(self);
tp->tp_free((PyObject*)self);
Copy link
Member

@Eclips4Eclips4Sep 26, 2024
edited
Loading

Choose a reason for hiding this comment

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

Suggested change
tp->tp_free((PyObject*)self);
tp->tp_free(self);

nit: there's no need to casting it toPyObject * since it's already aPyObject *

vstinner reacted with thumbs up emoji
Copy link
Member

@serhiy-storchakaserhiy-storchaka left a comment

Choose a reason for hiding this comment

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

LGTM.

@vstinner
Copy link
MemberAuthor

I will wait for a few Refleaks buildbots to complete before merging this change.

Eclips4 reacted with thumbs up emoji

@vstinner
Copy link
MemberAuthor

Four Refleaks workers completed: test_datetime still leaks, but that's unrelated to this fix. test_ast no longer leaks on these workers. I consider that the fix works as expected and merge my PR.

@vstinnervstinner merged commit257a20a intopython:mainSep 26, 2024
43 of 50 checks passed
@vstinnervstinner deleted the placeholder branchSeptember 26, 2024 14:50
@vstinner
Copy link
MemberAuthor

Four Refleaks workers completed: test_datetime still leaks, but that's unrelated to this fix.

See#124606 for test_datetime leak.

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

@Eclips4Eclips4Eclips4 approved these changes

@serhiy-storchakaserhiy-storchakaserhiy-storchaka approved these changes

@picnixzpicnixzpicnixz approved these changes

@ZeroIntensityZeroIntensityZeroIntensity approved these changes

@rhettingerrhettingerAwaiting requested review from rhettingerrhettinger is a code owner

Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

6 participants
@vstinner@Eclips4@bedevere-bot@serhiy-storchaka@picnixz@ZeroIntensity

[8]ページ先頭

©2009-2025 Movatter.jp