8000 gh-128657: fix _hashopenssl ref/data race by tom-pytel · Pull Request #128886 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-128657: fix _hashopenssl ref/data race #128886

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

Merged
merged 11 commits into from
Feb 8, 2025
Prev Previous commit
Next Next commit
added test and test_hashlib to list of tsan tests
  • Loading branch information
tom-pytel committed Jan 16, 2025
commit 35fd4ba04bc8c0d2d69bdbf32eedf5bfb3c5b402
1 change: 1 addition & 0 deletions Lib/test/libregrtest/tsan.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
'test_code',
'test_enum',
'test_functools',
'test_hashlib',
'test_httpservers',
'test_imaplib',
'test_importlib',
Expand Down
23 changes: 23 additions & 0 deletions Lib/test/test_hashlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,29 @@ def test_file_digest(self):
with open(os_helper.TESTFN, "wb") as f:
hashlib.file_digest(f, "sha256")

@unittest.skipUnless(support.check_sanitizer(thread=True), "only meaningful on free-threading")
def test_gh_128657(self):
def test_hashlib_sha256():
hash_obj = hashlib.sha256()

def closure(barrier):
barrier.wait()
test_hashlib_sha256()

num_workers = 40
num_runs = 20

for i in range(num_runs):
barrier = threading.Barrier(num_workers)
thrds = []

for i in range(num_workers):
thrds.append(thrd := threading.Thread(target=closure, args=(barrier,)))
thrd.start()

for thrd in thrds:
thrd.join()


if __name__ == "__main__":
unittest.main()
Loading
0