-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
gh-129983: fix data race in compile_template in sre.c #130015
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
Conversation
Modules/_sre/sre.c
Outdated
@@ -1167,13 +1167,21 @@ compile_template(_sremodulestate *module_state, | |||
PatternObject *pattern, PyObject *template) | |||
{ | |||
/* delegate to Python code */ | |||
PyObject *func = module_state->compile_template; | |||
PyObject *func = FT_ATOMIC_LOAD_PTR_RELAXED(module_state->compile_template); |
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.
Let's use FT_ATOMIC_LOAD_PTR
here.
FT_ATOMIC_LOAD_PTR_ACQUIRE
would probably also be fine, but I think symmetry between the load and store is generally a good idea.
I think we can leave the test out for now. I briefly looked at this yesterday, and the other tests in |
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!
@kumaraditya303 - is this okay with you? |
np :) |
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
Thanks @tom-pytel for the PR, and @kumaraditya303 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
Sorry, @tom-pytel and @kumaraditya303, I could not cleanly backport this to
|
Anyone want backport or should I do it? |
I did that already #130038 |
I am assuming the conversation was resolved on the side of the atomic?
I am not sure about the test added here for 3 reasons:
re.sub()
before this test so thatre._compile_template
doesn't get cached yet.The other option would be to make a separate test file just for this case? Overkill I think. So opinion on this requested, maybe don't need test for this?
compile_template
insre.c
#129983