Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
Fix rt.sections_elf_shared regression
Browse files Browse the repository at this point in the history
Causing spurious unittest failures on OSX.
See dlang@b22d813d0b16d.
  • Loading branch information
kinke committed Oct 14, 2018
1 parent 3299f8c commit 7f0e6cf
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/rt/sections_elf_shared.d
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,18 @@ else
*/
Array!(void[])* initTLSRanges() nothrow @nogc
{
return &_tlsRanges;
if (!_tlsRanges)
{
_tlsRanges = cast(Array!(void[])*)calloc(1, Array!(void[]).sizeof);
_tlsRanges || assert(0, "Could not allocate TLS range storage");
}
return _tlsRanges;
}

void finiTLSRanges(Array!(void[])* rngs) nothrow @nogc
{
rngs.reset();
.free(rngs);
}

void scanTLSRanges(Array!(void[])* rngs, scope ScanDG dg) nothrow
Expand Down Expand Up @@ -378,7 +384,7 @@ else
* Thread local array that contains TLS memory ranges for each
* library initialized in this thread.
*/
Array!(void[]) _tlsRanges;
Array!(void[])* _tlsRanges;

enum _rtLoading = false;
}
Expand Down Expand Up @@ -483,7 +489,7 @@ extern(C) void _d_dso_registry(void* arg)
}
foreach (p; _loadedDSOs) assert(p !is pdso);
_loadedDSOs.insertBack(pdso);
_tlsRanges.insertBack(pdso.tlsRange());
initTLSRanges().insertBack(pdso.tlsRange());
}

// don't initialize modules before rt_init was called (see Bugzilla 11378)
Expand Down

0 comments on commit 7f0e6cf

Please sign in to comment.