don't reset a segment thread id when iterating

This commit is contained in:
daanx 2024-06-03 18:19:45 -07:00
parent 537c51e227
commit 065f46cefb
2 changed files with 5 additions and 1 deletions

View File

@ -82,7 +82,10 @@ static bool mi_arena_segment_os_clear_abandoned(mi_segment_t* segment, bool take
segment->abandoned_os_prev = NULL;
mi_atomic_decrement_relaxed(&subproc->abandoned_count);
mi_atomic_decrement_relaxed(&subproc->abandoned_os_list_count);
mi_atomic_store_release(&segment->thread_id, _mi_thread_id());
if (take_lock) {
// don't set the thread_id when iterating
mi_atomic_store_release(&segment->thread_id, _mi_thread_id());
}
reclaimed = true;
}
if (take_lock) { mi_lock_release(&segment->subproc->abandoned_os_lock); }

View File

@ -836,6 +836,7 @@ void _mi_segment_page_abandon(mi_page_t* page, mi_segments_tld_t* tld) {
// Possibly clear pages and check if free space is available
static bool mi_segment_check_free(mi_segment_t* segment, size_t block_size, bool* all_pages_free)
{
mi_assert_internal(mi_atomic_load_relaxed(&segment->thread_id) == 0);
bool has_page = false;
size_t pages_used = 0;
size_t pages_used_empty = 0;