Skip to content

Commit 2685712

Browse files
committed
gh-159111: Mark remaining CPython-specific changes in vendored mimalloc with a comment
1 parent d3cdd16 commit 2685712

4 files changed

Lines changed: 5 additions & 2 deletions

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ terms of the MIT license. A copy of the license can be found in the file
102102
#define mi_decl_externc
103103
#endif
104104

105+
// CPython: upstream defines __wasi__ on Emscripten here. It is removed so that
106+
// CPython code can distinguish the two platforms (gh-158628).
105107

106108
// --------------------------------------------------------------------------
107109
// Internal functions

‎Objects/mimalloc/os.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ static void* mi_os_prim_alloc_aligned(size_t size, size_t alignment, bool commit
276276
else {
277277
// if not aligned, free it, overallocate, and unmap around it
278278
#if !MI_TRACK_ASAN
279+
// CPython: downgraded from _mi_warning_message, the warning is noisy in the test suite (gh-112027)
279280
_mi_verbose_message("unable to allocate aligned OS memory directly, fall back to over-allocation (size: 0x%zx bytes, address: %p, alignment: 0x%zx, commit: %d)\n", size, p, alignment, commit);
280281
#endif
281282
if (p != NULL) { mi_os_prim_free(p, size, (commit ? size : 0)); }

‎Objects/mimalloc/prim/unix/prim.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ static bool unix_detect_overcommit(void) {
124124
#if defined(__linux__)
125125
int fd = mi_prim_open("/proc/sys/vm/overcommit_memory", O_RDONLY);
126126
if (fd >= 0) {
127-
char buf[32] = {0};
127+
char buf[32] = {0}; // CPython: zero-initialize to avoid an MSAN report
128128
ssize_t nread = mi_prim_read(fd, &buf, sizeof(buf));
129129
mi_prim_close(fd);
130130
// <https://www.kernel.org/doc/Documentation/vm/overcommit-accounting>

‎Objects/mimalloc/random.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ uintptr_t _mi_os_random_weak(uintptr_t extra_seed) {
178178
}
179179

180180
static void mi_random_init_ex(mi_random_ctx_t* ctx, bool use_weak) {
181-
uint8_t key[32] = {0};
181+
uint8_t key[32] = {0}; // CPython: zero-initialize to avoid an MSAN report
182182
if (use_weak || !_mi_prim_random_buf(key, sizeof(key))) {
183183
// if we fail to get random data from the OS, we fall back to a
184184
// weak random source based on the current time

0 commit comments

Comments
 (0)