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

gh-120198: Stop the world when setting __class__ on free-threaded build by Fidget-Spinner · Pull Request #120672 · python/cpython · GitHub

/ cpython Public

gh-120198: Stop the world when setting __class__ on free-threaded build - #120672

Merged
Fidget-Spinner merged 8 commits into
python:mainfrom
Fidget-Spinner:class_stoptheworld
Jul 10, 2024
Merged

gh-120198: Stop the world when setting __class__ on free-threaded build#120672
Fidget-Spinner merged 8 commits into
python:mainfrom
Fidget-Spinner:class_stoptheworld

Conversation

Fidget-Spinner commented Jun 18, 2024
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

Comment thread Include/object.h Outdated
Comment thread Objects/typeobject.c Outdated
Comment thread Objects/typeobject.c Outdated
return -1;
goto err;
}
err:

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

To have a more regular try: ... finally: _PyEval_StartTheWorld() pattern, you can add an int res = -1; variable, replace goto err with goto done, and set res to 0 on success (3 lines above).

Copy link
Copy Markdown
Contributor

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

I think @vstinner's suggestion is fine. Or you can refactor the parts that should be in a stop-the-world call into it's own function, like we often do for locks.

Another advantage of moving the body to a separate function is that it makes it more clear what data crosses the stop-the-world boundary -- some data loaded before the stop-the-world call may not be valid after it.

Comment thread Objects/typeobject.c Outdated
Comment thread Objects/typeobject.c Outdated
Comment thread Objects/typeobject.c Outdated
Comment thread Include/internal/pycore_dict.h Outdated
int
_PyDict_DetachFromObject(PyDictObject *dict, PyObject *obj);

PyDictObject *_PyObject_materialize_managed_dict_lock_held(PyObject *);

Copy link
Copy Markdown
Contributor

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

Let's name this like the other functions: _PyObject_MaterializeManagedDict_LockHeld and move the definition up next to _PyObject_MaterializeManagedDict.

Comment thread Objects/typeobject.c Outdated
Comment thread Objects/typeobject.c Outdated
return -1;
goto err;
}
err:

Copy link
Copy Markdown
Contributor

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

I think @vstinner's suggestion is fine. Or you can refactor the parts that should be in a stop-the-world call into it's own function, like we often do for locks.

Another advantage of moving the body to a separate function is that it makes it more clear what data crosses the stop-the-world boundary -- some data loaded before the stop-the-world call may not be valid after it.

colesbury left a comment

Copy link
Copy Markdown
Contributor

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 with a few comments about comments.

I think this should be backported to 3.13

Comment thread Objects/typeobject.c Outdated
Comment thread Objects/typeobject.c Outdated
Comment thread Objects/typeobject.c Outdated
Comment thread Objects/typeobject.c Outdated
Fidget-Spinner merged commit 3bfc9c8 into python:main Jul 10, 2024

Copy link
Copy Markdown

Thanks @Fidget-Spinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

Copy link
Copy Markdown

Sorry, @Fidget-Spinner, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 3bfc9c831ad9a3dcf4457e842f1e612e93014a17 3.13

Fidget-Spinner deleted the class_stoptheworld branch July 10, 2024 18:02
Fidget-Spinner added a commit to Fidget-Spinner/cpython that referenced this pull request Jul 10, 2024
noahbkim pushed a commit to hudson-trading/cpython that referenced this pull request Jul 11, 2024
estyxx pushed a commit to estyxx/cpython that referenced this pull request Jul 17, 2024
hugovk removed the needs backport to 3.13 bugs and security fixes label Feb 26, 2025
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