gh-114271: Make `_thread.lock` thread-safe in free-threaded builds by mpage · Pull Request #116433 · python/cpython
…in free-threaded builds Previously, the `locked` field was set after releasing the lock. This reverses the order so that the `locked` field is set while the lock is still held. There is still one thread-safety issue where `locked` is checked prior to releasing the lock, however, in practice that will only be an issue when unlocking the lock is contended, which should be rare.
bot
mentioned this pull request
mpage
marked this pull request as ready for review
adorilson pushed a commit to adorilson/cpython that referenced this pull request
Mar 25, 2024…lds (python#116433) Previously, the `locked` field was set after releasing the lock. This reverses the order so that the `locked` field is set while the lock is still held. There is still one thread-safety issue where `locked` is checked prior to releasing the lock, however, in practice that will only be an issue when unlocking the lock is contended, which should be rare.
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request
Apr 17, 2024…lds (python#116433) Previously, the `locked` field was set after releasing the lock. This reverses the order so that the `locked` field is set while the lock is still held. There is still one thread-safety issue where `locked` is checked prior to releasing the lock, however, in practice that will only be an issue when unlocking the lock is contended, which should be rare.
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