8000 gh-130030: Fix crash on 32-bit Linux with free threading by colesbury · Pull Request #130043 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions 12 Objects/obmalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 7 additions & 5 deletions Python/gc_free_threading.c
Original file line number Diff line number Diff line change
Expand Up @@ -581,11 +581,13 @@ gc_mark_buffer_len(gc_mark_args_t *args)
}

// Returns number of free entry slots in buffer
#ifndef NDEBUG
static inline unsigned int
gc_mark_buffer_avail(gc_mark_args_t *args)
{
return BUFFER_SIZE - gc_mark_buffer_len(args);
}
#endif

static inline bool
gc_mark_buffer_is_empty(gc_mark_args_t *args)
Expand Down Expand Up @@ -1074,14 +1076,14 @@ mark_heap_visitor(const mi_heap_t *heap, const mi_heap_area_t *area,
return true;
}

_PyObject_ASSERT_WITH_MSG(op, gc_get_refs(op) >= 0,
"refcount is too small");

if (gc_is_alive(op) || !gc_is_unreachable(op)) {
// Object was already marked as reachable.
return true;
}

_PyObject_ASSERT_WITH_MSG(op, gc_get_refs(op) >= 0,
"refcount is too small");

// GH-129236: If we've seen an active frame without a valid stack pointer,
// then we can't collect objects with deferred references because we may
// have missed some reference to the object on the stack. In that case,
Expand Down Expand Up @@ -1178,10 +1180,10 @@ move_legacy_finalizer_reachable(struct collection_state *state);
static void
gc_prime_from_spans(gc_mark_args_t *args)
{
Py_ssize_t space = BUFFER_HI - gc_mark_buffer_len(args);
unsigned int space = BUFFER_HI - gc_mark_buffer_len(args);
// there should always be at least this amount of space
assert(space <= gc_mark_buffer_avail(args));
assert(space > 0);
assert(space <= BUFFER_HI);
gc_span_t entry = args->spans.stack[--args->spans.size];
// spans on the stack should always have one or more elements
assert(entry.start < entry.end);
Expand Down
Loading
0