]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.12] gh-105699: Use a Thread-Local Variable for PKGCONTEXT (gh-105740) (gh-105765)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 14 Jun 2023 01:34:26 +0000 (18:34 -0700)
committerGitHub <noreply@github.com>
Wed, 14 Jun 2023 01:34:26 +0000 (01:34 +0000)
commitbc997b38b66cd61ab2ba9697546c39472cb93ee3
tree1d315d7dd3738c81570791b2f3026ff4cdd2e779
parent26bc2cc06128890ac89492eca20e83abe0789c1c
[3.12] gh-105699: Use a Thread-Local Variable for PKGCONTEXT (gh-105740) (gh-105765)

This fixes a race during import. The existing _PyRuntimeState.imports.pkgcontext is shared between interpreters, and occasionally this would cause a crash when multiple interpreters were importing extensions modules at the same time.  To solve this we add a thread-local variable for the value.  We also leave the existing state (and infrequent race) in place for platforms that do not support thread-local variables.
(cherry picked from commit b87d2882754a7c273e2695c33384383eba380d7d)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
Python/import.c
Tools/c-analyzer/c_parser/parser/_regexes.py
Tools/c-analyzer/c_parser/preprocessor/gcc.py
Tools/c-analyzer/cpython/ignored.tsv