Skip to content
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

gh-111654: remove redundant decref on the eval stack value #111655

Merged
merged 1 commit into from
Nov 3, 2023

Conversation

aisk
Copy link
Member

@aisk aisk commented Nov 2, 2023

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.

@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
@@ -1550,6 +1548,7 @@ dummy_func(
}
Py_INCREF(value);
}
Py_DECREF(class_dict);
Copy link
Member

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?

Copy link
Member Author

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.

@JelleZijlstra JelleZijlstra self-requested a review November 2, 2023 19:15
Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

Thanks!

@JelleZijlstra JelleZijlstra added needs backport to 3.12 bug and security fixes and removed awaiting merge labels Nov 3, 2023
@JelleZijlstra JelleZijlstra merged commit 3a1b09e into python:main Nov 3, 2023
35 checks passed
@miss-islington-app
Copy link

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

@miss-islington-app
Copy link

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

@bedevere-app
Copy link

bedevere-app bot commented Nov 3, 2023

GH-111674 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 bug and security fixes label Nov 3, 2023
JelleZijlstra pushed a commit to JelleZijlstra/cpython that referenced this pull request Nov 3, 2023
…DEREF (pythonGH-111655)

(cherry picked from commit 3a1b09e)

Co-authored-by: AN Long <aisk@users.noreply.github.com>
@bedevere-bot
Copy link

⚠️⚠️⚠️ 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

@bedevere-bot
Copy link

⚠️⚠️⚠️ 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

JelleZijlstra added a commit that referenced this pull request Nov 3, 2023
…H-111655) (#111674)

(cherry picked from commit 3a1b09e)

Co-authored-by: AN Long <aisk@users.noreply.github.com>
@aisk aisk deleted the fix-crash branch November 9, 2023 16:04
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.

None yet

4 participants