summaryrefslogtreecommitdiffstats
path: root/Tools/c-analyzer/c_parser/preprocessor/gcc.py
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2023-06-14 00:58:23 (GMT)
committerGitHub <noreply@github.com>2023-06-14 00:58:23 (GMT)
commitb87d2882754a7c273e2695c33384383eba380d7d (patch)
tree55718e32fdacacf3dc3be2c8e6d00d02b9df193f /Tools/c-analyzer/c_parser/preprocessor/gcc.py
parentfcf0647cf2a78de2c2b603af2709d58c8567df67 (diff)
downloadcpython-b87d2882754a7c273e2695c33384383eba380d7d.zip
cpython-b87d2882754a7c273e2695c33384383eba380d7d.tar.gz
cpython-b87d2882754a7c273e2695c33384383eba380d7d.tar.bz2
gh-105699: Use a Thread-Local Variable for PKGCONTEXT (gh-105740)
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.
Diffstat (limited to 'Tools/c-analyzer/c_parser/preprocessor/gcc.py')
-rw-r--r--Tools/c-analyzer/c_parser/preprocessor/gcc.py1
1 files changed, 1 insertions, 0 deletions
diff --git a/Tools/c-analyzer/c_parser/preprocessor/gcc.py b/Tools/c-analyzer/c_parser/preprocessor/gcc.py
index c680f35..1476157 100644
--- a/Tools/c-analyzer/c_parser/preprocessor/gcc.py
+++ b/Tools/c-analyzer/c_parser/preprocessor/gcc.py
@@ -219,6 +219,7 @@ def _strip_directives(line, partial=0):
line = line[m.end():]
line = re.sub(r'__extension__', '', line)
+ line = re.sub(r'__thread\b', '_Thread_local', line)
while (m := COMPILER_DIRECTIVE_RE.match(line)):
before, _, _, closed = m.groups()