-
-
Notifications
You must be signed in to change notification settings - Fork 31.5k
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-128657: fix _hashopenssl ref/data race #128886
Conversation
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Misc/NEWS.d/next/Library/2025-01-15-15-45-21.gh-issue-128657.P5LNQA.rst
Outdated
Show resolved
Hide resolved
The implementation LGTM. You can reuse the reproducer in the issue as a test. See the devguide for writing tests. |
Are TSAN tests possible? Because that is the only way the issue shows up, other than as an extra refcount at a specific byte offset of the opaque |
Yeah, tests are run with TSan as part of CI. For example, on this PR: https://github.com/python/cpython/actions/runs/12809851053/job/35715616858?pr=128886 |
Still not sure how you want me to implement this test. |
You don't need to do anything special--just write the test. Python will be built with TSan integration, and races on that test will show up in CI. |
Done. Had to add |
I don't have much time today and tomorrow for in-depth rewview and there is some other stuff to do before reviewing this one, but I'll do it on Sunday or Monday. If I forget, just ping me back (or you can DM me on Discord @ZeroIntensity) |
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.
First round of review I forgot to send. I'll have more time starting on Monday to do the in-depth review.
Sent up requested changes, but I want to be clear, with or without the tsan fix, this test doesn't actually do anything useful (I have no tsan output or test failure when fix is removed).
|
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 @tom-pytel - this change looks good to me.
If the test doesn't do anything useful, would you please remove it? We can catch this race by running the existing haslib tests with --parallel-threads=4
. We'll need to make some minor adjustments to test_hashlib.py, but we can do that after this fix is merged.
This catches the race in `py_digest_by_name` that is fixed separately in pythongh-128886.
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.
LGTM!
I'll merge this next week if nobody else has further feedback or merges it before me. |
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.
a little tricky but seems solid.
Thanks @tom-pytel for the PR, and @gpshead for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
Sorry, @tom-pytel and @gpshead, I could not cleanly backport this to
|
@colesbury can you handle the backport? |
I think it would also be great to give @tom-pytel a chance to backport if he's up for it. |
(cherry picked from commit 6c67904) Co-authored-by: Tomasz Pytel <[email protected]>
GH-129852 is a backport of this pull request to the 3.13 branch. |
cherry_picker was giving me an error from git so I did this manually from the dry run, feel free to beat with stupid stick if I messes something up. Otherwise let me know and will do same for 3.12. |
GH-129853 is a backport of this pull request to the 3.13 branch. |
Yeah, you're supposed to get an error for git. That error is telling you to fix the merge conflicts 😅 No need for 3.12, free-threading doesn't exist there. |
No, it wasn't that, it was something weird git-related, am gonna post this as an issue unless you have an idea:
|
IIRC, that shows up if you don't have a local 3.13 branch from upstream. |
But cherry picker created the branch, and:
Or did I have to specify upstream on the command line?
It was a branch from
NM, I understand what u mean... |
Correct backport is here #129853 |
Fix a possible data and PY_EVP_MD refcount race in _hashopenssl.c in
py_digest_by_name()
under free-threading.