GeezerVison is showing github.com — gh-117657: Fix data races reported by TSAN in some set methods by aisk · Pull Request #120914 · python/cpython
Conversation
aisk
commented
Jun 23, 2024
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
set_add_key and set_discard_key have the same issue and should be fixed, although they have not been detected by TSAN.
After this change, the TSAN doesn't report data races for this method on my machine.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Thanks! This pattern occurs in a bunch of places outside of setobject.c. Can you fix those as well? I think it's worth fixing the entire pattern at once.
I think it's also probably worth refactoring the fast hash check into its own inline function (maybe in pycore_object.h or pycore_unicodeobject.h) that does the whole check the type, check the unicode hash, return it if it's not -1, otherwise delegate to PyObject_Hash().
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Thanks! This pattern occurs in a bunch of places outside of setobject.c. Can you fix those as well? I think it's worth fixing the entire pattern at once.
I think it's also probably worth refactoring the fast hash check into its own inline function (maybe in pycore_object.h or pycore_unicodeobject.h) that does the whole check the type, check the unicode hash, return it if it's not -1, otherwise delegate to PyObject_Hash().
Thanks for the review! I think this new function is not related to unicode object only, so I added it in pycore_object.h, and named it _PyObject_HashFast().
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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 - this looks good. Just minor comments about _PyObject_HashFast
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Thanks @aisk for the PR, and @colesbury for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this pull request
Jul 1, 2024
…ythonGH-120914)
Refactor the fast Unicode hash check into `_PyObject_HashFast` and use relaxed
atomic loads in the free-threaded build.
After this change, the TSAN doesn't report data races for this method.
(cherry picked from commit 294e724)
Co-authored-by: AN Long <[email protected]>
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Nice change, I like _PyObject_HashFast() which factorizes the code.
|
aisk reacted with heart emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
colesbury
pushed a commit
that referenced
this pull request
Jul 1, 2024
…GH-120914) (#121240)
Refactor the fast Unicode hash check into `_PyObject_HashFast` and use relaxed
atomic loads in the free-threaded build.
After this change, the TSAN doesn't report data races for this method.
(cherry picked from commit 294e724)
Co-authored-by: AN Long <[email protected]>
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️
Hi! The buildbot AMD64 Debian root 3.13 has failed when building commit 06fd745.
What do you need to do:
- Don't panic.
- Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
- Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/1441/builds/255) and take a look at the build logs.
- Check if the failure is related to this commit (06fd745) or if it is a false positive.
- 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/1441/builds/255
Failed tests:
Failed subtests:
- test_asyncio_repl_is_ok - test.test_repl.TestInteractiveInterpreter.test_asyncio_repl_is_ok
Summary of the results of the build (if available):
==
Click to see traceback logs
Traceback (most recent call last):
File "/root/buildarea/3.13.angelico-debian-amd64/build/Lib/asyncio/__main__.py", line 109, in run
raise OSError(errno.ENOTTY, "tty required", "stdin")
xiting asyncio REPL...
Fatal Python error: _enter_buffered_busy: could not acquire lock for <_io.BufferedWriter name='<stderr>'> at interpreter shutdown, possibly due to daemon threads
Python runtime state: finalizing (tstate=0x0000557e5090ff50)
Traceback (most recent call last):
xiting asyncio REPL...
File "/root/buildarea/3.13.angelico-debian-amd64/build/Lib/asyncio/__main__.py", line 109, in run
raise OSError(errno.ENOTTY, "tty required", "stdin")
Fatal Python error: _enter_buffered_busy: could not acquire lock for <_io.BufferedWriter name='<stderr>'> at interpreter shutdown, possibly due to daemon threads
Python runtime state: finalizing (tstate=0x0000561498692f50)
Traceback (most recent call last):
File "/root/buildarea/3.13.angelico-debian-amd64/build/Lib/test/test_repl.py", line 199, in test_asyncio_repl_is_ok
assert_python_ok("-m", "asyncio")
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/root/buildarea/3.13.angelico-debian-amd64/build/Lib/test/support/script_helper.py", line 180, in assert_python_ok
return _assert_python(True, *args, **env_vars)
File "/root/buildarea/3.13.angelico-debian-amd64/build/Lib/test/support/script_helper.py", line 165, in _assert_python
res.fail(cmd_line)
~~~~~~~~^^^^^^^^^^
File "/root/buildarea/3.13.angelico-debian-amd64/build/Lib/test/support/script_helper.py", line 75, in fail
raise AssertionError("Process return code is %d\n"
...<13 lines>...
err))
AssertionError: Process return code is -6
command line: ['/root/buildarea/3.13.angelico-debian-amd64/build/python', '-X', 'faulthandler', '-I', '-m', 'asyncio']
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Buildbot failure is unrelated to this PR.
See #119909
|
aisk reacted with eyes emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Akasurde
pushed a commit
to Akasurde/cpython
that referenced
this pull request
Jul 3, 2024
…ython#120914)
Refactor the fast Unicode hash check into `_PyObject_HashFast` and use relaxed
atomic loads in the free-threaded build.
After this change, the TSAN doesn't report data races for this method.
estyxx
pushed a commit
to estyxx/cpython
that referenced
this pull request
Jul 17, 2024
…ython#120914)
Refactor the fast Unicode hash check into `_PyObject_HashFast` and use relaxed
atomic loads in the free-threaded build.
After this change, the TSAN doesn't report data races for this method.
Reviewers
markshannon
Awaiting requested review from markshannon
markshannon is a code owner
methane
Awaiting requested review from methane
methane is a code owner
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
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.
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.
|