Bug 15975 – TLS not scanned correctly for main thread

Status
RESOLVED
Resolution
INVALID
Severity
major
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2016-05-01T09:03:00Z
Last change time
2016-05-05T21:25:38Z
Keywords
pull
Assigned to
nobody
Creator
r.sagitario

Comments

Comment #0 by r.sagitario — 2016-05-01T09:03:21Z
I don't have an reliable reproduction of the problem, but LDC builds sometimes fail due to memory being collected while still being referenced. It turns out that TLS memory of the memory can be misaligned: import core.stdc.stdio; void* tls; void main() { printf("&tls = %p\n", &tls); } outputs &tls = 0x7fe7da7e79bc for 64-bit builds. Please note that the address is not aligned to 8 bytes!
Comment #1 by r.sagitario — 2016-05-01T09:11:04Z
Comment #2 by r.sagitario — 2016-05-02T07:45:21Z
Sorry, screwed up the test completely. It is not the variable that is misaligned, but the range scanned by the GC. Use this test program: import core.stdc.stdio; import rt.sections; void* tls; void main() { foreach (ref sg; SectionGroup) { foreach (rng; sg.gcRanges) printf("glob: beg = %p end = %p\n", rng.ptr, rng.ptr + rng.length); } if (auto arr = initTLSRanges()) foreach (rng; *arr) printf("tls: beg = %p end = %p\n", rng.ptr, rng.ptr + rng.length); printf("&tls = %p\n", &tls); } It prints: glob: beg = 0x6299f0 end = 0x62e3a8 tls: beg = 0x7fd37dfdb717 end = 0x7fd37dfdba40 &tls = 0x7fd37dfdb710
Comment #3 by r.sagitario — 2016-05-05T21:25:38Z
This is LDC specific.