gh-151218: Replace sys.flags in PyConfig_Set()#151402
Conversation
PyConfig_Set() and sys.set_int_max_str_digits() now replace sys.flags, instead of modifying sys.flags in-place. Modifying sys.flags in-place can lead to data races when multiple threads are reading or writing sys.flags in parallel. Use _Py_atomic functions to get and set max_str_digits members.
|
I built Python with If we agree that this change is the right approach, I will add a non-regression test. |
skirpichev
left a comment
There was a problem hiding this comment.
I think it's a correct approach.
Add test_sys to "./python -m test --tsan" tests.
|
I added a thread test to I also added some simple tests on get_int_max_str_digits() / set_int_max_str_digits() (in test_sys). |
|
Python 3.13 is not affected: I modified |
PyConfig_Set() and sys.set_int_max_str_digits() now replace sys.flags, instead of modifying sys.flags in-place.
Modifying sys.flags in-place can lead to data races when multiple threads are reading or writing sys.flags in parallel.
Use _Py_atomic functions to get and set max_str_digits members.
sys_set_flagwhensys.set_int_max_str_digits()is called concurrently with free-threaded build #151218