-
-
Notifications
You must be signed in to change notification settings - Fork 421
Fix 21465: Allocate _tlsRanges in C heap #3308
Conversation
|
Thanks for your pull request and interest in making D better, @omerfirmak! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "stable + druntime#3308" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable, did you encounter the same on gdc as well @Geod24 ?
src/rt/sections_elf_shared.d
Outdated
| static Array!(void[])* x = null; | ||
| if (x is null) | ||
| x = cast(Array!(void[])*).calloc(1, Array!(void[]).sizeof); | ||
| assert(x); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is probably too soon to throw Errors, and safeAssert a better fit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only alternative is to crash or error in initTLSRanges. I am making the change to safeAssert
f667d1b to
7ebfaaa
Compare
Similar to the issue fixed here dlang#1655 (comment) , static version of the sections_elf_shared accesses TLS of a dead thread. The simplest fix is to allocate _tlsRanges somewhere that would persist outside of the thread scope, for example the C heap. This was encountered while porting ldc 1.24.0 to Alpine Linux which uses Musl. https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/14364 But this issue should be affecting other libc implementations as well.
7ebfaaa to
c67efba
Compare
Similar to the issue fixed here #1655 (comment) ,
static version of the sections_elf_shared accesses TLS of a dead thread. The simplest fix is to allocate
_tlsRanges somewhere that would persist outside of the thread scope, for example the C heap.
This was encountered while porting ldc 1.24.0 to Alpine Linux which uses Musl.
https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/14364 But this issue should
be affecting other libc implementations as well.
Fixes https://issues.dlang.org/show_bug.cgi?id=21465