Commit 8fecc4b
committed
Fix crash in pthread_tsd_cleanup on macOS ARM64 (#1177)
Complete the NULL handling fix from commit 515047b by also checking for
NULL page entries in the 2-level page map lookup.
The issue occurs on macOS ARM64 during pthread TSD (thread-specific data)
cleanup when thread_local C++ objects are destroyed. During this late
cleanup phase, the TLS for mimalloc may already be invalidated, causing
_mi_checked_ptr_page to return NULL for valid pointers.
Commit 515047b ('improve free on macos') changed the sub==NULL case to
return _mi_page_empty instead of NULL, but missed the case where
sub[sub_idx] is NULL. This commit adds the same NULL check for the page
entry itself.
Includes a regression test that reproduces the crash scenario.1 parent 7a2a411 commit 8fecc4b
File tree
3 files changed
+27
-1
lines changed- include/mimalloc
- test
3 files changed
+27
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
767 | 767 | | |
768 | 768 | | |
769 | 769 | | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
770 | 782 | | |
771 | 783 | | |
772 | 784 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
578 | 578 | | |
579 | 579 | | |
580 | 580 | | |
581 | | - | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
582 | 584 | | |
583 | 585 | | |
584 | 586 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
0 commit comments