FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

GH-94851: fix immortal objects refcounting in compiler by kumaraditya303 · Pull Request #95040 · python/cpython · GitHub

Repository navigation

GH-94851: fix immortal objects refcounting in compiler - #95040

Merged
corona10 merged 1 commit into
python:mainfrom
kumaraditya303:fix-refcnt
Jul 20, 2022
Merged

corona10 merged 1 commit into
python:mainfrom
kumaraditya303:fix-refcnt

Conversation

kumaraditya303 commented Jul 20, 2022 •
edited
Loading

Copy link
Copy Markdown
Contributor

kumaraditya303 requested a review from corona10 July 20, 2022 07:04
kumaraditya303 changed the title GH94851: fix immortal objects refcounting in compiler GH-94851: fix immortal objects refcounting in compiler Jul 20, 2022
kumaraditya303 added the needs backport to 3.11 only security fixes label Jul 20, 2022

corona10 commented Jul 20, 2022 •
edited
Loading

Copy link
Copy Markdown
Member

@kumaraditya303 Thanks Kumar

I was also curious about this code also when you submitted the related patch before.

  1. It will be helpful to review if you can suggest reproducible code as you did before.
  2. There are several _Py_STR related codes that don't increase reference count when they are used.
    Should they be updated? and if yes, Would you like to submit the one-shot patch?

Copy link
Copy Markdown
Contributor Author

There are several _Py_STR related codes that don't increase reference count when they are used.

it depends on its usage, if you are owning the object or returning it from a function then incref is required else it is not required.

kumaraditya303 commented Jul 20, 2022 •
edited
Loading

Copy link
Copy Markdown
Contributor Author

It will be helpful to review if you can suggest reproducible code as you did before.

If you follow the macro, it is capturing a reference to the new object so incref is required.

See comment : /* Same as ADDOP_LOAD_CONST, but steals a reference. */

corona10 commented Jul 20, 2022 •
edited
Loading

Copy link
Copy Markdown
Member

@kumaraditya303

a = 1
print(f'{a:d} {a:d}  {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d}')
./python.exe -X showrefcount tt.py
1 1  1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
[-1 refs, 0 blocks]

Copy link
Copy Markdown
Contributor Author
a = 1
print(f'{a:d} {a:d}  {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d} {a:d}')
./python.exe -X showrefcount tt.py
1 1  1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
[-1 refs, 0 blocks]

Nice repro, thanks!

Copy link
Copy Markdown
Member

And I checked that your patch fix this issue.

./python.exe -X showrefcount tt.py
1 1  1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
[0 refs, 0 blocks]

corona10 left a comment •
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM.

Please submit the reproducible code if possible it can reduce the reviewer's time and help understanding context :)
I know your patch is correct but reproducible code makes sure what your patch fixes exactly.

corona10 merged commit 7476154 into python:main Jul 20, 2022

Copy link
Copy Markdown
Contributor

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

kumaraditya303 deleted the fix-refcnt branch July 20, 2022 09:53

Copy link
Copy Markdown

GH-95049 is a backport of this pull request to the 3.11 branch.

bedevere-bot removed the needs backport to 3.11 only security fixes label Jul 20, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 20, 2022
…h-95040)

(cherry picked from commit 7476154)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>

Copy link
Copy Markdown
Member

I will merge backport patch after my dinner :)

miss-islington added a commit that referenced this pull request Jul 20, 2022
(cherry picked from commit 7476154)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL