-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Windows 7 i686 does not reliably align 16 byte aligned thread locals #138903
Copy link
Copy link
Closed
Labels
A-alignArea: alignment control (`repr(align(N))` and so on)Area: alignment control (`repr(align(N))` and so on)A-thread-localsArea: Thread local storage (TLS)Area: Thread local storage (TLS)C-bugCategory: This is a bug.Category: This is a bug.O-windows-7OS: Windows 7 or Windows Server 2008 R2 or etc.OS: Windows 7 or Windows Server 2008 R2 or etc.O-x86_32Target: x86 processors, 32 bit (like i686-*) (also known as IA-32, i386, i586, i686)Target: x86 processors, 32 bit (like i686-*) (also known as IA-32, i386, i586, i686)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-alignArea: alignment control (`repr(align(N))` and so on)Area: alignment control (`repr(align(N))` and so on)A-thread-localsArea: Thread local storage (TLS)Area: Thread local storage (TLS)C-bugCategory: This is a bug.Category: This is a bug.O-windows-7OS: Windows 7 or Windows Server 2008 R2 or etc.OS: Windows 7 or Windows Server 2008 R2 or etc.O-x86_32Target: x86 processors, 32 bit (like i686-*) (also known as IA-32, i386, i586, i686)Target: x86 processors, 32 bit (like i686-*) (also known as IA-32, i386, i586, i686)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
The following program will reliably crash using the
i686-win7-windows-msvctarget on a Windows 7 installation using latest nightly.I tried this code:
This reliably produces the following panic.
My experience with/understanding of thread locals is mostly limited to what i've researched due to this issue, but it does appear that an i686 targeted executable on Windows 7 does not reliably align thread locals when 16 byte alignment is requested. I didn't see issues with even 8 byte alignment. I was not able to reproduce this issue on Windows 10.
Given that i686 win7 is a likely pretty niche target, do you think it would be reasonable to partially undo #123257 by disabling
has_thread_localfori686-win7-windows-msvc. It seems that i686 on Windows 7 can't be trusted for alignment of thread locals. I did test adjusting thei686-win7-windows-msvctarget in a local build of the compiler and it does appear to work for the test program.The 16 byte aligned thread local came from
matrixmultiplywhich actually works around misalignment internally, but compiled this way I get the UB check panic anyway. I can certainly work around it by seeing ifmatrixmultiplycan be patched, or just doing that locally. But it seems like this should be fixed in the compiler ideally.