Skip to content

Commit 75528df

Browse files
Move tracemalloc_reentrant_key to _PyRuntimeState.
1 parent 0f84737 commit 75528df

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

Include/internal/pycore_tracemalloc.h

+5
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,14 @@ struct tracemalloc_traceback {
6464

6565
struct _tracemalloc_runtime_state {
6666
struct _PyTraceMalloc_Config config;
67+
6768
/* Protected by the GIL */
6869
struct {
6970
PyMemAllocatorEx mem;
7071
PyMemAllocatorEx raw;
7172
PyMemAllocatorEx obj;
7273
} allocators;
74+
7375
#if defined(TRACE_RAW_MALLOC)
7476
PyThread_type_lock tables_lock;
7577
#endif
@@ -96,6 +98,8 @@ struct _tracemalloc_runtime_state {
9698
/* domain (unsigned int) => traces (_Py_hashtable_t).
9799
Protected by TABLES_LOCK(). */
98100
_Py_hashtable_t *domains;
101+
102+
Py_tss_t reentrant_key;
99103
};
100104

101105
#define _tracemalloc_runtime_state_INIT \
@@ -105,6 +109,7 @@ struct _tracemalloc_runtime_state {
105109
.tracing = 0, \
106110
.max_nframe = 1, \
107111
}, \
112+
.reentrant_key = Py_tss_NEEDS_INIT, \
108113
}
109114

110115

Modules/_tracemalloc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ tracemalloc_error(const char *format, ...)
102102
#if defined(TRACE_RAW_MALLOC)
103103
#define REENTRANT_THREADLOCAL
104104

105-
static Py_tss_t tracemalloc_reentrant_key = Py_tss_NEEDS_INIT;
105+
#define tracemalloc_reentrant_key _PyRuntime.tracemalloc.reentrant_key
106106

107107
/* Any non-NULL pointer can be used */
108108
#define REENTRANT Py_True

Tools/c-analyzer/cpython/globals-to-fix.tsv

-1
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,6 @@ Modules/faulthandler.c - old_stack -
378378
## state
379379

380380
Modules/_tracemalloc.c - tracemalloc_empty_traceback -
381-
Modules/_tracemalloc.c - tracemalloc_reentrant_key -
382381
Modules/faulthandler.c faulthandler_dump_traceback reentrant -
383382
Modules/signalmodule.c - is_tripped -
384383
Modules/signalmodule.c - signal_global_state -

0 commit comments

Comments
 (0)