Fix crash on exit on Android with destroy_on_exit #974
+4
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When
mi_option_destroy_on_exit
is set, the call to_mi_heap_unsafe_destroy_all
(which callsmi_prim_get_default_heap
, which in turn callspthread_getspecific
with_mi_heap_default_key
) is made after the call to_mi_prim_thread_done_auto_done
(which callspthread_key_delete
with_mi_heap_default_key
).It appears that, at least on Android, calling
pthread_getspecific
afterpthread_key_delete
returns a null value, which causesmi_prim_get_default_heap
to return the empty heap, and this line to crash due toheap->tld
being null.This change moves the call to
_mi_prim_thread_done_auto_done
after all of the uses ofmi_prim_get_default_heap
, so accessing the default heap is possible.