gh-115491: Keep some fields valid across allocations (free-threading) (#115573)

This avoids filling the memory occupied by ob_tid, ob_ref_local, and
ob_ref_shared with debug bytes (e.g., 0xDD) in mimalloc in the
free-threaded build.
This commit is contained in:
Sam Gross 2024-02-20 10:36:40 -05:00 committed by GitHub
parent c0b0c2f201
commit cc82e33af9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 33 additions and 25 deletions

View file

@ -312,6 +312,7 @@ typedef struct mi_page_s {
uint8_t is_committed : 1; // `true` if the page virtual memory is committed
uint8_t is_zero_init : 1; // `true` if the page was initially zero initialized
uint8_t tag : 4; // tag from the owning heap
uint8_t debug_offset; // number of bytes to preserve when filling freed or uninitialized memory
// layout like this to optimize access in `mi_malloc` and `mi_free`
uint16_t capacity; // number of blocks committed, must be the first field, see `segment.c:page_clear`
@ -553,6 +554,7 @@ struct mi_heap_s {
mi_heap_t* next; // list of heaps per thread
bool no_reclaim; // `true` if this heap should not reclaim abandoned pages
uint8_t tag; // custom identifier for this heap
uint8_t debug_offset; // number of bytes to preserve when filling freed or uninitialized memory
};