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-111654: remove redundant decref on the eval stack value by aisk · Pull Request #111655 · python/cpython

Conversation

@aisk

@aisk aisk commented Nov 2, 2023 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

This is just like #109123, but for another OP code. In the error path, the class_dict is still on the value stack, and the error unwinding process will call decref on it. So we should remove the decref in error path, or there will be a double decref, and cause the ref count to negative in the GC process, and leads to the runtime crash.

  • Issue: redundant decref on the eval stack value in LOAD_FROM_DICT_OR_DEREF in error path #111654

Sorry, something went wrong.

Uh oh!

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

All reactions
@aisk
remove redundant decref on the eval stack value in LOAD_FROM_DICT_OR_…
036fc0f
…DEREF in

error path
@aisk
aisk requested a review from iritkatriel as a code owner November 2, 2023 17:06
@bedevere-app bedevere-app Bot added the awaiting review label Nov 2, 2023
@bedevere-app bedevere-app Bot mentioned this pull request Nov 2, 2023
redundant decref on the eval stack value in LOAD_FROM_DICT_OR_DEREF in error path #111654
Closed
@aisk aisk changed the title gh-111654: remove redundant decref on the eval stack value in LOAD_FROM_DICT_OR_… gh-111654: remove redundant decref on the eval stack value Nov 2, 2023
iritkatriel
iritkatriel reviewed Nov 2, 2023
View reviewed changes
Comment thread Python/bytecodes.c
}
Py_INCREF(value);
}
Py_DECREF(class_dict);

@iritkatriel iritkatriel Nov 2, 2023 •
edited
Loading

Uh oh!

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

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 DECREF won't happen if we GOTO_ERROR on line 1547. Is that the idea?

Sorry, something went wrong.

Uh oh!

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

All reactions

@aisk aisk Nov 2, 2023

Copy link
Copy Markdown
Member Author

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.

Yes, this is the expected behavior. I'll add some notes on the first comment.

Sorry, something went wrong.

Uh oh!

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

All reactions
@JelleZijlstra
JelleZijlstra self-requested a review November 2, 2023 19:15
JelleZijlstra
JelleZijlstra approved these changes Nov 3, 2023
View reviewed changes

@JelleZijlstra JelleZijlstra 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.

Thanks!

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 review labels Nov 3, 2023
@JelleZijlstra JelleZijlstra added needs backport to 3.12 only security fixes and removed awaiting merge labels Nov 3, 2023
@JelleZijlstra
JelleZijlstra merged commit 3a1b09e into python:main Nov 3, 2023
@miss-islington-app

miss-islington-app Bot commented Nov 3, 2023

Copy link
Copy Markdown

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

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 Nov 3, 2023

Copy link
Copy Markdown

Sorry, @aisk and @JelleZijlstra, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 3a1b09e6d070778d78d81084f88d37377d38ee9b 3.12
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 assigned JelleZijlstra Nov 3, 2023
@bedevere-app

bedevere-app Bot commented Nov 3, 2023

Copy link
Copy Markdown

GH-111674 is a backport of this pull request to the 3.12 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.12 only security fixes label Nov 3, 2023
JelleZijlstra pushed a commit to JelleZijlstra/cpython that referenced this pull request Nov 3, 2023
@aisk @JelleZijlstra
[3.12] pythongh-111654: remove redundant decref in LOAD_FROM_DICT_OR_…
ca1da24
…DEREF (pythonGH-111655)

(cherry picked from commit 3a1b09e)

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

bedevere-bot commented Nov 3, 2023

Copy link
Copy Markdown

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

Hi! The buildbot s390x RHEL7 3.x has failed when building commit 3a1b09e.

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/179/builds/5864) and take a look at the build logs.
  4. Check if the failure is related to this commit (3a1b09e) 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/179/builds/5864

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

==

Click to see traceback logs
remote: Enumerating objects: 14, done.�[K
remote: Counting objects:   7% (1/14)�[K
remote: Counting objects:  14% (2/14)�[K
remote: Counting objects:  21% (3/14)�[K
remote: Counting objects:  28% (4/14)�[K
remote: Counting objects:  35% (5/14)�[K
remote: Counting objects:  42% (6/14)�[K
remote: Counting objects:  50% (7/14)�[K
remote: Counting objects:  57% (8/14)�[K
remote: Counting objects:  64% (9/14)�[K
remote: Counting objects:  71% (10/14)�[K
remote: Counting objects:  78% (11/14)�[K
remote: Counting objects:  85% (12/14)�[K
remote: Counting objects:  92% (13/14)�[K
remote: Counting objects: 100% (14/14)�[K
remote: Counting objects: 100% (14/14), done.�[K
remote: Compressing objects:   8% (1/12)�[K
remote: Compressing objects:  16% (2/12)�[K
remote: Compressing objects:  25% (3/12)�[K
remote: Compressing objects:  33% (4/12)�[K
remote: Compressing objects:  41% (5/12)�[K
remote: Compressing objects:  50% (6/12)�[K
remote: Compressing objects:  58% (7/12)�[K
remote: Compressing objects:  66% (8/12)�[K
remote: Compressing objects:  75% (9/12)�[K
remote: Compressing objects:  83% (10/12)�[K
remote: Compressing objects:  91% (11/12)�[K
remote: Compressing objects: 100% (12/12)�[K
remote: Compressing objects: 100% (12/12), done.�[K
remote: Total 14 (delta 4), reused 5 (delta 2), pack-reused 0�[K
From https://github.com/python/cpython
 * branch            main       -> FETCH_HEAD
Note: checking out '3a1b09e6d070778d78d81084f88d37377d38ee9b'.

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 performing another checkout.

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

  git checkout -b new_branch_name

HEAD is now at 3a1b09e... gh-111654: remove redundant decref in LOAD_FROM_DICT_OR_DEREF (#111655)
Switched to and reset branch 'main'

Objects/unicodeobject.c: In function ‘unicode_endswith’:
Objects/unicodeobject.c:13021:23: warning: ‘subobj’ may be used uninitialized in this function [-Wmaybe-uninitialized]
             substring = PyTuple_GET_ITEM(subobj, i);
                       ^
Objects/unicodeobject.c: In function ‘unicode_startswith’:
Objects/unicodeobject.c:12967:23: warning: ‘subobj’ may be used uninitialized in this function [-Wmaybe-uninitialized]
             substring = PyTuple_GET_ITEM(subobj, i);
                       ^
Python/instrumentation.c: In function ‘allocate_instrumentation_data’:
Python/instrumentation.c:1489:9: warning: missing braces around initializer [-Wmissing-braces]
         code->_co_monitoring->local_monitors = (_Py_LocalMonitors){ 0 };
         ^
Python/instrumentation.c:1489:9: warning: (near initialization for ‘(anonymous).tools’) [-Wmissing-braces]
Python/instrumentation.c:1490:9: warning: missing braces around initializer [-Wmissing-braces]
         code->_co_monitoring->active_monitors = (_Py_LocalMonitors){ 0 };
         ^
Python/instrumentation.c:1490:9: warning: (near initialization for ‘(anonymous).tools’) [-Wmissing-braces]
./Modules/_xxinterpchannelsmodule.c: In function ‘_channel_get_info’:
./Modules/_xxinterpchannelsmodule.c:2129:21: warning: missing braces around initializer [-Wmissing-braces]
     *info = (struct channel_info){0};
                     ^
./Modules/_xxinterpchannelsmodule.c:2129:21: warning: (near initialization for ‘(anonymous).status’) [-Wmissing-braces]

make: *** [buildbottest] Error 3
All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-bot

bedevere-bot commented Nov 3, 2023

Copy link
Copy Markdown

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

Hi! The buildbot AMD64 Windows11 Bigmem 3.x has failed when building commit 3a1b09e.

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/1079/builds/2652) and take a look at the build logs.
  4. Check if the failure is related to this commit (3a1b09e) 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/1079/builds/2652

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

==

Click to see traceback logs
remote: Enumerating objects: 14, done.        
remote: Counting objects:   7% (1/14)        
remote: Counting objects:  14% (2/14)        
remote: Counting objects:  21% (3/14)        
remote: Counting objects:  28% (4/14)        
remote: Counting objects:  35% (5/14)        
remote: Counting objects:  42% (6/14)        
remote: Counting objects:  50% (7/14)        
remote: Counting objects:  57% (8/14)        
remote: Counting objects:  64% (9/14)        
remote: Counting objects:  71% (10/14)        
remote: Counting objects:  78% (11/14)        
remote: Counting objects:  85% (12/14)        
remote: Counting objects:  92% (13/14)        
remote: Counting objects: 100% (14/14)        
remote: Counting objects: 100% (14/14), done.        
remote: Compressing objects:   8% (1/12)        
remote: Compressing objects:  16% (2/12)        
remote: Compressing objects:  25% (3/12)        
remote: Compressing objects:  33% (4/12)        
remote: Compressing objects:  41% (5/12)        
remote: Compressing objects:  50% (6/12)        
remote: Compressing objects:  58% (7/12)        
remote: Compressing objects:  66% (8/12)        
remote: Compressing objects:  75% (9/12)        
remote: Compressing objects:  83% (10/12)        
remote: Compressing objects:  91% (11/12)        
remote: Compressing objects: 100% (12/12)        
remote: Compressing objects: 100% (12/12), done.        
remote: Total 14 (delta 4), reused 5 (delta 2), pack-reused 0        
From https://github.com/python/cpython
 * branch                  main       -> FETCH_HEAD
Note: switching to '3a1b09e6d070778d78d81084f88d37377d38ee9b'.

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 3a1b09e6d0 gh-111654: remove redundant decref in LOAD_FROM_DICT_OR_DEREF (#111655)
Switched to and reset branch 'main'

Could Not Find R:\buildarea\3.x.ambv-bb-win11.bigmem\build\Lib\*.pyc
The system cannot find the file specified.
Could Not Find R:\buildarea\3.x.ambv-bb-win11.bigmem\build\PCbuild\python*.zip

Could Not Find R:\buildarea\3.x.ambv-bb-win11.bigmem\build\PCbuild\python*.zip
All reactions

Sorry, something went wrong.

Uh oh!

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

FullteaR pushed a commit to FullteaR/cpython that referenced this pull request Nov 3, 2023
@aisk @FullteaR
pythongh-111654: remove redundant decref in LOAD_FROM_DICT_OR_DEREF (p…
73584a0
…ython#111655)
JelleZijlstra added a commit that referenced this pull request Nov 3, 2023
@JelleZijlstra @aisk
[3.12] gh-111654: remove redundant decref in LOAD_FROM_DICT_OR_DEREF (G…
1a95ad6
…H-111655) (#111674)

(cherry picked from commit 3a1b09e)

Co-authored-by: AN Long <[email protected]>
@aisk
aisk deleted the fix-crash branch November 9, 2023 16:04
aisk added a commit to aisk/cpython that referenced this pull request Feb 11, 2024
@aisk
pythongh-111654: remove redundant decref in LOAD_FROM_DICT_OR_DEREF (p…
5b8aa03
…ython#111655)
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
@aisk @Glyphack
pythongh-111654: remove redundant decref in LOAD_FROM_DICT_OR_DEREF (p…
252775d
…ython#111655)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@iritkatriel iritkatriel iritkatriel left review comments
@JelleZijlstra JelleZijlstra JelleZijlstra approved these changes

Uh oh!

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

Assignees

@JelleZijlstra JelleZijlstra

Labels

None yet

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.

4 participants

@aisk @bedevere-bot @JelleZijlstra @iritkatriel
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.