-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
gh-129824: fix data races in subinterpreters under TSAN #135794
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
base: main
Are you sure you want to change the base?
Conversation
🤖 New build scheduled with the buildbot fleet by @kumaraditya303 for commit be846e8 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F135794%2Fmerge If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again. |
This also fixes #116909 so more of test_capi tests can be enabled under free-threading TSAN (will do in follow up). |
@@ -1359,6 +1358,19 @@ _PyType_LookupByVersion(unsigned int version) | |||
#error "_Py_ATTR_CACHE_UNUSED must be bigger than max" | |||
#endif | |||
|
|||
static inline unsigned int | |||
get_next_global_version_tag(void) |
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.
Call this something like "next_global_version_tag(void)" instead of "get_next_global_version_tag".
"get_" makes it sound like a function that retrieves the next version tag without modifying it.
do { | ||
old = _Py_atomic_load_uint_relaxed(&_PyRuntime.types.next_version_tag); | ||
if (old >= _Py_MAX_GLOBAL_TYPE_VERSION_TAG) { | ||
return (unsigned int)-1; |
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.
Use 0 for an invalid version
This fixes the data races in typeobject.c in subinterpreters under free-threading. The type flags are only modified in the main interpreter as all static types are first initialized in main interpreter. With the fix the test_interpreter_pool tests have no data races in typeobject.c under TSAN (there are still some unrelated data races in module exec like posix and struct).