Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
/ druntime Public archive

Fix 21465: Allocate _tlsRanges in C heap#3308

Merged
dlang-bot merged 1 commit intodlang:stablefrom
omerfirmak:fix-21465-stable
Dec 13, 2020
Merged

Fix 21465: Allocate _tlsRanges in C heap#3308
dlang-bot merged 1 commit intodlang:stablefrom
omerfirmak:fix-21465-stable

Conversation

@omerfirmak
Copy link
Contributor

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

@omerfirmak omerfirmak requested a review from Burgos as a code owner December 9, 2020 17:05
@dlang-bot
Copy link
Contributor

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 verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

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 references

Your 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 locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "stable + druntime#3308"

Copy link
Member

@ibuclaw ibuclaw left a 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 ?

static Array!(void[])* x = null;
if (x is null)
x = cast(Array!(void[])*).calloc(1, Array!(void[]).sizeof);
assert(x);
Copy link
Contributor

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.

Copy link
Contributor Author

@omerfirmak omerfirmak Dec 12, 2020

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

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.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants