-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Windows 7 i686 does not reliably align 16 byte aligned thread locals #138903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@rustbot label: +O-windows-7 +O-x86_32 +A-thread-locals +A-align -needs-triage +T-compiler |
Windows 7 does not respect 16 byte alignment for thread locals on i686 builds. Rust 1.79 changed i686 windows builds to use native thread local support. As a result, using `matrixmultiply` on i686 win7 builds leads to a UB check panic nounwind when run on Windows 7. See <rust-lang/rust#138903> for more info. This change adds `i686-win7-windows-msvc` as an excluded target for the alignment attribute on `MaskBuffer`.
So I dug into this a bit, and was able to reproduce. Thankfully there's a bit of a similar issue in GNU targets, with some instructions on how to investigate: #135719 (comment)
Characteristics 5242880 is 0x500000 in hex, which equals IMAGE_SCN_ALIGN_16BYTES, which matches what we expect. However, when running the reproducer, I indeed get the same crashes. So this would indicate that Windows 7 does not respect the I'll make a PR to put has_thread_local back to false. |
Disable has_thread_local on i686-win7-windows-msvc On Windows 7 32-bit, the alignment characteristic of the TLS Directory don't appear to be respected by the PE Loader, leading to crashes. As a result, let's disable has_thread_local to make sure TLS goes through the emulation layer. Fixes rust-lang#138903
Disable has_thread_local on i686-win7-windows-msvc On Windows 7 32-bit, the alignment characteristic of the TLS Directory don't appear to be respected by the PE Loader, leading to crashes. As a result, let's disable has_thread_local to make sure TLS goes through the emulation layer. Fixes rust-lang#138903
Disable has_thread_local on i686-win7-windows-msvc On Windows 7 32-bit, the alignment characteristic of the TLS Directory don't appear to be respected by the PE Loader, leading to crashes. As a result, let's disable has_thread_local to make sure TLS goes through the emulation layer. Fixes rust-lang#138903
Rollup merge of rust-lang#140007 - roblabla:fix-win7, r=ChrisDenton Disable has_thread_local on i686-win7-windows-msvc On Windows 7 32-bit, the alignment characteristic of the TLS Directory don't appear to be respected by the PE Loader, leading to crashes. As a result, let's disable has_thread_local to make sure TLS goes through the emulation layer. Fixes rust-lang#138903
The following program will reliably crash using the
i686-win7-windows-msvc
target 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_local
fori686-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-msvc
target 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
matrixmultiply
which actually works around misalignment internally, but compiled this way I get the UB check panic anyway. I can certainly work around it by seeing ifmatrixmultiply
can be patched, or just doing that locally. But it seems like this should be fixed in the compiler ideally.The text was updated successfully, but these errors were encountered: