FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-117657: Fix data race in `compare_unicode_unicode_threadsafe` by colesbury · Pull Request #131746 · python/cpython · GitHub

/ cpython Public

gh-117657: Fix data race in compare_unicode_unicode_threadsafe - #131746

Merged
colesbury merged 1 commit into
python:mainfrom
colesbury:gh-117657-dict-unicode
Mar 26, 2025
Merged

gh-117657: Fix data race in compare_unicode_unicode_threadsafe#131746
colesbury merged 1 commit into
python:mainfrom
colesbury:gh-117657-dict-unicode

Conversation

colesbury commented Mar 25, 2025
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Contributor

We can't safely check the type of the found key until we incref it or if we know that it's immortal.

We can't safely check the type of the found key until we safely incref
it or if we know that it's immortal.

Copy link
Copy Markdown
Contributor Author

Should fix the race seen https://github.com/python/cpython/actions/runs/14068787835/job/39397782588:

WARNING: ThreadSanitizer: data race (pid=10960)
  Read of size 8 at 0x7f2924[22](https://github.com/python/cpython/actions/runs/14068787835/job/39397782588#step:14:23)03a8 by thread T844:
    #0 _Py_TYPE /home/runner/work/cpython/cpython/./Include/object.h:270:20 (python+0x3083db) (BuildId: e5c9b61ad47fa51cd82b89cf8a8b0d92a470990a)
    #1 Py_IS_TYPE /home/runner/work/cpython/cpython/./Include/object.h:293:12 (python+0x3083db)
    #2 compare_unicode_unicode_threadsafe /home/runner/work/cpython/cpython/Objects/dictobject.c:1415:5 (python+0x3083db)
    #3 do_lookup /home/runner/work/cpython/cpython/Objects/dictobject.c:1012:[23](https://github.com/python/cpython/actions/runs/14068787835/job/39397782588#step:14:24) (python+0x307a08) (BuildId: e5c9b61ad47fa51cd82b89cf8a8b0d92a470990a)
    #4 unicodekeys_lookup_unicode_threadsafe /home/runner/work/cpython/cpython/Objects/dictobject.c:1440:12 (python+0x2eefde) (BuildId: e5c9b61ad47fa51cd82b89cf8a8b0d92a470990a)
...
Previous write of size 8 at 0x7f29242203a8 by thread T842:
    #0 __tsan_memset <null> (python+0xdc7a8) (BuildId: e5c9b61ad47fa51cd82b89cf8a8b0d92a470990a)
    #1 fill_mem_debug /home/runner/work/cpython/cpython/Objects/obmalloc.c (python+0x35acb1) (BuildId: e5c9b61ad47fa51cd82b89cf8a8b0d92a470990a)
    #2 _PyMem_DebugRawAlloc /home/runner/work/cpython/cpython/Objects/obmalloc.c:2805:9 (python+0x35acb1)
    #3 _PyMem_DebugRawMalloc /home/runner/work/cpython/cpython/Objects/obmalloc.c:2821:12 (python+0x35acb1)
    #4 _PyMem_DebugMalloc /home/runner/work/cpython/cpython/Objects/obmalloc.c:2986:12 (python+0x35acb1)
    #5 PyObject_Malloc /home/runner/work/cpython/cpython/Objects/obmalloc.c:1394:12 (python+0x359[68](https://github.com/python/cpython/actions/runs/14068787835/job/39397782588#step:14:69)d) (BuildId: e5c9b61ad47fa51cd82b89cf8a8b0d92a470990a)
    #6 PyUnicode_New /home/runner/work/cpython/cpython/Objects/unicodeobject.c:1409:24 (python+0x3cc4fd) (BuildId: e5c9b61ad47fa51cd82b89cf8a8b0d92a470990a)

colesbury merged commit 5abff69 into python:main Mar 26, 2025
colesbury deleted the gh-117657-dict-unicode branch March 26, 2025 13:02
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 1, 2025
pythongh-131746)

We can't safely check the type of the found key until we incref it or if we know that it's immortal.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL