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) |
picnixz
left a comment
There was a problem hiding this comment.
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). |
This catches the race in `py_digest_by_name` that is fixed separately in pythongh-128886.
|
I'll merge this next week if nobody else has further feedback or merges it before me. |
gpshead
left a comment
There was a problem hiding this comment.
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 <tompytel@gmail.com>
|
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.