diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-06-14 01:34:26 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-14 01:34:26 (GMT) |
commit | bc997b38b66cd61ab2ba9697546c39472cb93ee3 (patch) | |
tree | 1d315d7dd3738c81570791b2f3026ff4cdd2e779 /Tools/c-analyzer/c_parser/parser/_regexes.py | |
parent | 26bc2cc06128890ac89492eca20e83abe0789c1c (diff) | |
download | cpython-bc997b38b66cd61ab2ba9697546c39472cb93ee3.zip cpython-bc997b38b66cd61ab2ba9697546c39472cb93ee3.tar.gz cpython-bc997b38b66cd61ab2ba9697546c39472cb93ee3.tar.bz2 |
[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>
Diffstat (limited to 'Tools/c-analyzer/c_parser/parser/_regexes.py')
-rw-r--r-- | Tools/c-analyzer/c_parser/parser/_regexes.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Tools/c-analyzer/c_parser/parser/_regexes.py b/Tools/c-analyzer/c_parser/parser/_regexes.py index b7f22b1..5695daf 100644 --- a/Tools/c-analyzer/c_parser/parser/_regexes.py +++ b/Tools/c-analyzer/c_parser/parser/_regexes.py @@ -58,6 +58,7 @@ _KEYWORD = textwrap.dedent(r''' extern | register | static | + _Thread_local | typedef | const | @@ -137,7 +138,7 @@ COMPOUND_TYPE_KIND = r'(?: \b (?: struct | union | enum ) \b )' ####################################### # variable declarations -_STORAGE = 'auto register static extern'.split() +_STORAGE = 'auto register static extern _Thread_local'.split() STORAGE_CLASS = rf'(?: \b (?: {" | ".join(_STORAGE)} ) \b )' TYPE_QUALIFIER = r'(?: \b (?: const | volatile ) \b )' PTR_QUALIFIER = rf'(?: [*] (?: \s* {TYPE_QUALIFIER} )? )' |