Skip to content

gh-145036: Fix data race for list capacity#145365

Open
bkap123 wants to merge 3 commits intopython:mainfrom
bkap123:list-thread-race
Open

gh-145036: Fix data race for list capacity#145365
bkap123 wants to merge 3 commits intopython:mainfrom
bkap123:list-thread-race

Conversation

@bkap123
Copy link
Contributor

@bkap123 bkap123 commented Feb 28, 2026

Changes list___sizeof___impl to use list_capacity() when determining size of a list object in order to prevent a data race.

Also, not exactly sure what to do for a test. The current test fails on main only when configured with TSan. Any feedback/suggestions would be greatly appreciated.

…e-145036.70Kbfz.rst

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
self.assertEqual(foo(list(range(10))), 45)

# gh-145036: race condition with list.__sizeof__()
def test_list_sizeof_free_threaded_build(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add this under test_free_threading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants