Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 326119d

Browse filesBrowse files
authored
gh-112529: Use _PyThread_Id() in mimalloc in free-threaded build (#115488)
The free-threaded GC uses mimallocs segment thread IDs to restore the overwritten `ob_tid` thread ids in PyObjects. For that reason, it's important that PyObjects and mimalloc use the same identifiers.
1 parent a95b1a5 commit 326119d
Copy full SHA for 326119d

File tree

2 files changed

+13
-4
lines changed
Filter options

2 files changed

+13
-4
lines changed

‎Include/internal/mimalloc/mimalloc/prim.h

Copy file name to clipboardExpand all lines: Include/internal/mimalloc/mimalloc/prim.h
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,13 @@ extern bool _mi_process_is_initialized; // has mi_process_init been
131131

132132
static inline mi_threadid_t _mi_prim_thread_id(void) mi_attr_noexcept;
133133

134-
#if defined(_WIN32)
134+
#ifdef MI_PRIM_THREAD_ID
135+
136+
static inline mi_threadid_t _mi_prim_thread_id(void) mi_attr_noexcept {
137+
return MI_PRIM_THREAD_ID();
138+
}
139+
140+
#elif defined(_WIN32)
135141

136142
#define WIN32_LEAN_AND_MEAN
137143
#include <windows.h>

‎Include/internal/pycore_mimalloc.h

Copy file name to clipboardExpand all lines: Include/internal/pycore_mimalloc.h
+6-3Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ typedef enum {
2020
#include "pycore_pymem.h"
2121

2222
#ifdef WITH_MIMALLOC
23-
#define MI_DEBUG_UNINIT PYMEM_CLEANBYTE
24-
#define MI_DEBUG_FREED PYMEM_DEADBYTE
25-
#define MI_DEBUG_PADDING PYMEM_FORBIDDENBYTE
23+
# ifdef Py_GIL_DISABLED
24+
# define MI_PRIM_THREAD_ID _Py_ThreadId
25+
# endif
26+
# define MI_DEBUG_UNINIT PYMEM_CLEANBYTE
27+
# define MI_DEBUG_FREED PYMEM_DEADBYTE
28+
# define MI_DEBUG_PADDING PYMEM_FORBIDDENBYTE
2629
#ifdef Py_DEBUG
2730
# define MI_DEBUG 1
2831
#else

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.