GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-151524: Avoid using instrumentation callback result after Py_DECREF by lpyu001 · Pull Request #151525 · python/cpython

Conversation

@lpyu001

@lpyu001 lpyu001 commented Jun 16, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor
  • Issue: instrumentation.c: Use-after-Py_DECREF comparison in call_one_instrument #151524

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@lpyu001
pythongh-151524: Avoid using instrumentation callback result after Py…
a4cc0af
…_DECREF
@bedevere-app bedevere-app Bot added the awaiting review label Jun 16, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Jun 16, 2026
instrumentation.c: Use-after-Py_DECREF comparison in call_one_instrument #151524
Closed
@chris-eibl
chris-eibl self-requested a review June 16, 2026 05:28
chris-eibl
chris-eibl requested changes Jun 16, 2026
View reviewed changes

@chris-eibl chris-eibl left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The change lgtm, but I'd create a news entry, like almost all of the fixes for the umbrella issue #146102 did so far.

cc @pablogsal

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting changes and removed awaiting review labels Jun 16, 2026
@bedevere-app

bedevere-app Bot commented Jun 16, 2026

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lpyu001
add NEWS
137a1bf
@lpyu001

lpyu001 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

The change lgtm, but I'd create a news entry, like almost all of the fixes for the umbrella issue #146102 did so far.

cc @pablogsal

I’ve submitted the news entry.thanks

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

chris-eibl
chris-eibl approved these changes Jun 16, 2026
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting changes labels Jun 16, 2026
sobolevn
sobolevn reviewed Jun 16, 2026
View reviewed changes

@sobolevn sobolevn left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Question: was it ever tested? Or was just the RC of res higher than 1, so no crash happened?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Misc/NEWS.d/next/Core_and_Builtins/2026-06-16-13-50-13.gh-issue-151377.mCqrGg.rst Outdated
@@ -0,0 +1,2 @@
Avoid comparing the result of a ``sys.monitoring`` callback after

@sobolevn sobolevn Jun 16, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This would be a user-facing news entry. Users care about crashes (which could happen here), not about RC :)
Let's rephrase it.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

chris-eibl reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
ZeroIntensity
ZeroIntensity requested changes Jun 16, 2026
View reviewed changes

@ZeroIntensity ZeroIntensity left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This isn't UB. _PyInstrumentation_DISABLE is an immortal object; Py_DECREF operations on it are a no-op.

>>> import sys
>>> sys._is_immortal(sys.monitoring.DISABLE)
True

That said, I do agree that it's misleading. Let's either remove the Py_DECREF call entirely and/or add an assertion that it's immortal.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

chris-eibl reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread Misc/NEWS.d/next/Core_and_Builtins/2026-06-16-13-50-13.gh-issue-151377.mCqrGg.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added awaiting changes and removed awaiting merge labels Jun 16, 2026
@bedevere-app

bedevere-app Bot commented Jun 16, 2026

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ZeroIntensity ZeroIntensity added the skip news label Jun 16, 2026
@lpyu001
update
67821dc
@aisk

aisk commented Jul 21, 2026

Copy link
Copy Markdown
Member

Hi @lpyu001 I see you made some update on this PR, and currently I think it look fine. Can you reply "I have made the requested changes; please review again" in the comments as the bot said, to require other reviewers continue the work?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lpyu001

lpyu001 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added awaiting change review and removed awaiting changes labels Jul 22, 2026
@bedevere-app

bedevere-app Bot commented Jul 22, 2026

Copy link
Copy Markdown

Thanks for making the requested changes!

@chris-eibl, @ZeroIntensity: please review the changes made to this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app
bedevere-app Bot requested review from ZeroIntensity and chris-eibl July 22, 2026 01:18
chris-eibl
chris-eibl approved these changes Jul 23, 2026
View reviewed changes

@chris-eibl chris-eibl left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Lgtm and helps me who didn't realize _PyInstrumentation_DISABLE is immortal 👍

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting change review labels Jul 23, 2026
ZeroIntensity
ZeroIntensity approved these changes Jul 23, 2026
View reviewed changes
@lpyu001

lpyu001 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

The PR has been mergeable for two weeks. Could we go ahead and merge it? @ZeroIntensity @chris-eibl

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

aisk
aisk approved these changes Aug 7, 2026
View reviewed changes
@ZeroIntensity
ZeroIntensity merged commit 52bed26 into python:main Aug 7, 2026
56 of 59 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting merge label Aug 7, 2026
@ZeroIntensity ZeroIntensity added needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Aug 7, 2026
@miss-islington-app

miss-islington-app Bot commented Aug 7, 2026

Copy link
Copy Markdown

Thanks @lpyu001 for the PR, and @ZeroIntensity for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington-app

miss-islington-app Bot commented Aug 7, 2026

Copy link
Copy Markdown

Thanks @lpyu001 for the PR, and @ZeroIntensity for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington-app

miss-islington-app Bot commented Aug 7, 2026

Copy link
Copy Markdown

Thanks @lpyu001 for the PR, and @ZeroIntensity for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app

bedevere-app Bot commented Aug 7, 2026

Copy link
Copy Markdown

GH-155349 is a backport of this pull request to the 3.14 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Aug 7, 2026
@bedevere-app

bedevere-app Bot commented Aug 7, 2026

Copy link
Copy Markdown

GH-155350 is a backport of this pull request to the 3.15 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Aug 7, 2026
@bedevere-app

bedevere-app Bot commented Aug 7, 2026

Copy link
Copy Markdown

GH-155351 is a backport of this pull request to the 3.13 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label Aug 7, 2026
ZeroIntensity pushed a commit that referenced this pull request Aug 7, 2026
@miss-islington @lpyu001
[3.13] gh-151524: Make it clearer that _PyInstrumentation_DISABLE i…
2e19855
…s immortal in the code (GH-151525) (GH-155351)

(cherry picked from commit 52bed26)

Co-authored-by: stevens <[email protected]>
ZeroIntensity pushed a commit that referenced this pull request Aug 7, 2026
@miss-islington @lpyu001
[3.14] gh-151524: Make it clearer that _PyInstrumentation_DISABLE i…
87bacf1
…s immortal in the code (GH-151525) (GH-155349)

(cherry picked from commit 52bed26)

Co-authored-by: stevens <[email protected]>
@bedevere-bot

bedevere-bot commented Aug 7, 2026

Copy link
Copy Markdown

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

Hi! The buildbot AMD64 Arch Linux Asan Debug 3.13 (tierless) has failed when building commit 2e19855.

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/1439/builds/1152) and take a look at the build logs.
  4. Check if the failure is related to this commit (2e19855) 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/1439/builds/1152

Failed tests:

  • test_io

Failed subtests:

  • test_daemon_threads_shutdown_stdout_deadlock - test.test_io.CMiscIOTest.test_daemon_threads_shutdown_stdout_deadlock
  • test_daemon_threads_shutdown_stderr_deadlock - test.test_io.CMiscIOTest.test_daemon_threads_shutdown_stderr_deadlock

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

==

Click to see traceback logs
Traceback (most recent call last):
  File "/buildbot/buildarea/3.13.pablogsal-arch-x86_64.asan_debug/build/Lib/test/test_io.py", line 4755, in test_daemon_threads_shutdown_stderr_deadlock
    self.check_daemon_threads_shutdown_deadlock('stderr')
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/buildbot/buildarea/3.13.pablogsal-arch-x86_64.asan_debug/build/Lib/test/test_io.py", line 4743, in check_daemon_threads_shutdown_deadlock
    self.assertRegex(err, pattern)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
AssertionError: Regex didn't match: "Fatal Python error: _enter_buffered_busy: could not acquire lock for <(_io\\.)?BufferedWriter name='<stderr>'> at interpreter shutdown, possibly due to daemon threads" not found in '...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
...............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................


Traceback (most recent call last):
  File "/buildbot/buildarea/3.13.pablogsal-arch-x86_64.asan_debug/build/Lib/test/test_io.py", line 4755, in test_daemon_threads_shutdown_stderr_deadlock
    self.check_daemon_threads_shutdown_deadlock('stderr')
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/buildbot/buildarea/3.13.pablogsal-arch-x86_64.asan_debug/build/Lib/test/test_io.py", line 4743, in check_daemon_threads_shutdown_deadlock
    self.assertRegex(err, pattern)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
AssertionError: Regex didn't match: "Fatal Python error: _enter_buffered_busy: could not acquire lock for <(_io\\.)?BufferedWriter name='<stderr>'> at interpreter shutdown, possibly due to daemon threads" not found in '....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................


Traceback (most recent call last):
  File "/buildbot/buildarea/3.13.pablogsal-arch-x86_64.asan_debug/build/Lib/test/test_io.py", line 4750, in test_daemon_threads_shutdown_stdout_deadlock
    self.check_daemon_threads_shutdown_deadlock('stdout')
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/buildbot/buildarea/3.13.pablogsal-arch-x86_64.asan_debug/build/Lib/test/test_io.py", line 4743, in check_daemon_threads_shutdown_deadlock
    self.assertRegex(err, pattern)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot

bedevere-bot commented Aug 7, 2026

Copy link
Copy Markdown

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

Hi! The buildbot AMD64 Arch Linux Usan Function 3.13 (tierless) has failed when building commit 2e19855.

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/1601/builds/821) and take a look at the build logs.
  4. Check if the failure is related to this commit (2e19855) 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/1601/builds/821

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

Click to see traceback logs
Note: switching to '2e19855a1734a47780b42cfcdc9e3f31976c3e7c'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 2e19855a1734a [3.13] gh-151524: Make it clearer that `_PyInstrumentation_DISABLE` is immortal in the code (GH-151525) (GH-155351)
Switched to and reset branch '3.13'

rror: unable to open output file 'Python/pythonrun.o': 'No space left on device'
1 error generated.
make: *** [Makefile:3042: Python/pythonrun.o] Error 1

find: ‘build’: No such file or directory
find: ‘build’: No such file or directory
find: ‘build’: No such file or directory
find: ‘build’: No such file or directory
make: [Makefile:3132: clean-retain-profile] Error 1 (ignored)
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

hugovk pushed a commit that referenced this pull request Aug 8, 2026
@miss-islington @lpyu001
[3.15] gh-151524: Make it clearer that _PyInstrumentation_DISABLE i…
a8a3b24
…s immortal in the code (GH-151525) (#155350)

gh-151524: Make it clearer that `_PyInstrumentation_DISABLE` is immortal in the code (GH-151525)
(cherry picked from commit 52bed26)

Co-authored-by: stevens <[email protected]>
mbeijen pushed a commit to mbeijen/cpython that referenced this pull request Aug 14, 2026
@lpyu001 @mbeijen
pythongh-151524: Make it clearer that _PyInstrumentation_DISABLE is…
c19e850
… immortal in the code (pythonGH-151525)
@lpyu001
lpyu001 deleted the fix-use-after-Py_DECREF-comparison2 branch September 23, 2026 02:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@sobolevn sobolevn sobolevn left review comments
@aisk aisk aisk approved these changes
@ZeroIntensity ZeroIntensity ZeroIntensity approved these changes
@chris-eibl chris-eibl chris-eibl approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@lpyu001 @aisk @bedevere-bot @sobolevn @ZeroIntensity @chris-eibl
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.