diff --git a/src/rt/sections_elf_shared.d b/src/rt/sections_elf_shared.d index 539da0b0c1..914df2d5b4 100644 --- a/src/rt/sections_elf_shared.d +++ b/src/rt/sections_elf_shared.d @@ -286,6 +286,7 @@ else void finiTLSRanges(Array!(void[])* rngs) nothrow @nogc { rngs.reset(); + .free(rngs); } void scanTLSRanges(Array!(void[])* rngs, scope ScanDG dg) nothrow @@ -369,7 +370,13 @@ else * Thread local array that contains TLS memory ranges for each * library initialized in this thread. */ - @property ref Array!(void[]) _tlsRanges() @nogc nothrow { static Array!(void[]) x; return x; } + @property ref Array!(void[]) _tlsRanges() @nogc nothrow { + static Array!(void[])* x = null; + if (x is null) + x = cast(Array!(void[])*).calloc(1, Array!(void[]).sizeof); + safeAssert(x !is null, "Failed to allocate TLS ranges"); + return *x; + } //Array!(void[]) _tlsRanges; enum _rtLoading = false;