gh-130030: Fix crash on 32-bit Linux with free threading (gh-130043)

The `gc_get_refs` assertion needs to be after we check the alive and
unreachable bits. Otherwise, `ob_tid` may store the actual thread id
instead of the computed `gc_refs`, which may trigger the assertion if
the `ob_tid` looks like a negative value.

Also fix a few type warnings on 32-bit systems.
This commit is contained in:
Sam Gross 2025-02-12 18:09:15 -05:00 committed by GitHub
parent 791cdfe141
commit e09442089e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 11 deletions

View file

@ -3297,12 +3297,12 @@ static bool _collect_alloc_stats(
static void
py_mimalloc_print_stats(FILE *out)
{
fprintf(out, "Small block threshold = %zd, in %u size classes.\n",
MI_SMALL_OBJ_SIZE_MAX, MI_BIN_HUGE);
fprintf(out, "Medium block threshold = %zd\n",
MI_MEDIUM_OBJ_SIZE_MAX);
fprintf(out, "Large object max size = %zd\n",
MI_LARGE_OBJ_SIZE_MAX);
fprintf(out, "Small block threshold = %zu, in %u size classes.\n",
(size_t)MI_SMALL_OBJ_SIZE_MAX, MI_BIN_HUGE);
fprintf(out, "Medium block threshold = %zu\n",
(size_t)MI_MEDIUM_OBJ_SIZE_MAX);
fprintf(out, "Large object max size = %zu\n",
(size_t)MI_LARGE_OBJ_SIZE_MAX);
mi_heap_t *heap = mi_heap_get_default();
struct _alloc_stats stats;