mimalloc icon indicating copy to clipboard operation
mimalloc copied to clipboard

Fix crash in pthread_tsd_cleanup on macOS ARM64 (#1177)

Open austenstone opened this issue 4 weeks ago • 2 comments

Fixes #1177

On macOS ARM64, freeing memory during thread exit can crash when thread_local C++ objects are involved. The issue is that _mi_checked_ptr_page checks for sub == NULL but not for sub[sub_idx] == NULL - commit 515047b fixed the first case but missed the second.

This adds the missing NULL check so both cases return _mi_page_empty consistently.

austenstone avatar Nov 26 '25 22:11 austenstone

@microsoft-github-policy-service agree company="Microsoft"

austenstone avatar Nov 26 '25 22:11 austenstone

@austenstone I'm digging further, but this change trips the UB sanitizer on my ARM Mac when landed against the dev3 branch. I see you've landed it against the dev3-cdb branch, which I can't find documented anywhere, so that might be my problem.

bazineta avatar Nov 30 '25 14:11 bazineta

@austenstone I'm digging further, but this change trips the UB sanitizer on my ARM Mac when landed against the dev3 branch. I see you've landed it against the dev3-cdb branch, which I can't find documented anywhere, so that might be my problem.

Yes, it is not recommended to use the dev3-cdb branch. I believe this issue is not present for the dev3 branch (or dev2 or dev1) (at least, I cannot reproduce it). Let me know if switching to dev3 fixes your probem?

daanx avatar Dec 03 '25 02:12 daanx