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-125323: Remove some unsafe stackref decrefs by Fidget-Spinner · Pull Request #125324 · python/cpython

Conversation

@Fidget-Spinner

@Fidget-Spinner Fidget-Spinner commented Oct 11, 2024 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Works towards #125323

  • Issue: Unsafe DECREFs of borrowed references in the interpreter. #125323

Sorry, something went wrong.

Uh oh!

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

All reactions
@Fidget-Spinner
Fix unsafe stackref decrefs
3c52e5c
@Fidget-Spinner
Fidget-Spinner requested a review from markshannon as a code owner October 11, 2024 15:31
@bedevere-app bedevere-app Bot mentioned this pull request Oct 11, 2024
Unsafe DECREFs of borrowed references in the interpreter. #125323
Closed
@bedevere-app bedevere-app Bot added the awaiting core review label Oct 11, 2024
@Fidget-Spinner

Fidget-Spinner commented Oct 11, 2024

Copy link
Copy Markdown
Member Author

@markshannon this needs benchmarking

All reactions

Sorry, something went wrong.

Uh oh!

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

@Fidget-Spinner Fidget-Spinner added the skip news label Oct 11, 2024
@markshannon

markshannon commented Oct 12, 2024 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Does this really fix the unsafe decrefs, or just some of them?

It isn't just the _Py_DECREF_SPECIALIZED, it is also the DECREF_INPUTS_AND_REUSE_FLOAT and _Py_DECREF_NO_DEALLOC. (I see you've also removed the _Py_DECREF_NO_DEALLOC)

I can also see one unsafe Py_DECREFs in RERAISE, there may be more.

this needs benchmarking

There's not much point if we already know it's going to be slower.
We should replace _Py_DECREF_SPECIALIZED with PyStackRef_CLOSE_SPECIALIZED to avoid the slowdown.

All reactions

Sorry, something went wrong.

Uh oh!

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

@Fidget-Spinner

Fidget-Spinner commented Oct 12, 2024

Copy link
Copy Markdown
Member Author

I can also see one unsafe Py_DECREFs in RERAISE, there may be more.

I manually went through every Py_DECREF in bytecodes.c. That Py_DECREF is safe. It's a PyStackRef_AsPyObjectSteal then Py_DECREF, not a borrow.

All reactions

Sorry, something went wrong.

Uh oh!

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

@Fidget-Spinner

Fidget-Spinner commented Oct 12, 2024

Copy link
Copy Markdown
Member Author

it is also the DECREF_INPUTS_AND_REUSE_FLOAT ~and

I don't know how to fix that without tanking performance. The way they behave doesn't conform to the stackref semantics at all.

All reactions

Sorry, something went wrong.

Uh oh!

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

Fidget-Spinner added 2 commits October 12, 2024 22:05
@Fidget-Spinner
Use close specialized
e128941
@Fidget-Spinner
regen cases
8278d07
@Fidget-Spinner Fidget-Spinner changed the title gh-125323: Fix unsafe stackref decrefs gh-125323: Remove some unsafe stackref decrefs Oct 12, 2024
@markshannon

markshannon commented Oct 14, 2024

Copy link
Copy Markdown
Member

Failures are the usual suspects.

All reactions

Sorry, something went wrong.

Uh oh!

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

@markshannon

markshannon commented Oct 14, 2024

Copy link
Copy Markdown
Member

Performance is a wash, as I would have expected.

So, lets' leave the DECREF_INPUTS_AND_REUSE_FLOAT macros for another PR and merge this.

All reactions

Sorry, something went wrong.

Uh oh!

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

markshannon
markshannon approved these changes Oct 14, 2024
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Oct 14, 2024
@markshannon
markshannon merged commit 4b358ee into python:main Oct 14, 2024
@bedevere-app bedevere-app Bot removed the awaiting merge label Oct 14, 2024
@Fidget-Spinner
Fidget-Spinner deleted the fix_unsafe_refcounting branch October 14, 2024 08:53
@sobolevn sobolevn mentioned this pull request Oct 14, 2024
gh-125470: Fix warning in Python/generated_cases.c.h #125471
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

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

2 participants

@Fidget-Spinner @markshannon
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.