Fix thread ID getter on Android ARM/AArch64#384
Merged
daanx merged 1 commit intomicrosoft:devfrom Apr 22, 2021
kdrag0n:fix-android-thread-id
Merged
Fix thread ID getter on Android ARM/AArch64#384daanx merged 1 commit intomicrosoft:devfrom kdrag0n:fix-android-thread-id
daanx merged 1 commit intomicrosoft:devfrom
kdrag0n:fix-android-thread-id
Conversation
Android's Bionic libc stores the thread ID in TLS slot 1 instead of 0 on 32-bit ARM and AArch64. Slot 0 contains a pointer to the ELF DTV (Dynamic Thread Vector) instead, which is constant for each loaded DSO. Because mimalloc uses the thread ID to determine whether operations are thread-local or cross-thread (atomic), all threads having the same ID causes internal data structures to get corrupted quickly when multiple threads are using the allocator: mimalloc: assertion failed: at "external/mimalloc/src/page.c":563, mi_page_extend_free assertion: "page->local_free == NULL" mimalloc: assertion failed: at "external/mimalloc/src/page.c":74, mi_page_is_valid_init assertion: "page->used <= page->capacity" mimalloc: assertion failed: at "external/mimalloc/src/page.c":100, mi_page_is_valid_init assertion: "page->used + free_count == page->capacity" mimalloc: assertion failed: at "external/mimalloc/src/page.c":74, mi_page_is_valid_init assertion: "page->used <= page->capacity" Add support for Android's alternate TLS layout to fix the crashes in multi-threaded use cases. Fixes #376.
Collaborator
|
@kdrag0n this is great! Thanks for figuring this out as I cannot test myself :-) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Android's Bionic libc stores the thread ID in TLS slot 1 instead of 0 on 32-bit ARM and AArch64. Slot 0 contains a pointer to the ELF DTV (Dynamic Thread Vector) instead, which is constant for each loaded DSO.
Because mimalloc uses the thread ID to determine whether operations are thread-local or cross-thread (atomic), all threads having the same ID causes internal data structures to get corrupted quickly when multiple threads are using the allocator:
Add support for Android's alternate TLS layout to fix the crashes in multi-threaded use cases.
Fixes #376.