microsoft / SymCrypt

Cryptographic library
MIT License
660 stars 68 forks source link

MSVC 2022 17.8 compiler bug causes SymCryptAesGcmEncryptStitchedYmm_2048 to crash on Alder Lake CPUs #35

Closed Myriachan closed 7 months ago

Myriachan commented 7 months ago

Visual Studio 2022 17.8 causes SymCryptAesGcmEncryptStitchedYmm_2048 to crash if run on an Alder Lake CPU. This is because the compiler incorrectly assumes that VAES and VPCLMULQDQ imply AVX-512 support, which is wrong. It then generates AVX-512 code and this crashes on Alder Lake, whose CPUID has VAES and VPCLMULQDQ but not AVX-512.

Reporting here for reference in case you want to work around it. https://developercommunity.visualstudio.com/t/Compiler-incorrectly-assumes-VAES-and-VP/10578785

mlindgren commented 7 months ago

Hi @Myriachan, thanks for your report. This is a known issue that has already been reported to the compiler team: https://developercommunity.visualstudio.com/t/Illegal-Instruction-AVX512/10511452 A fix should be available soon.

In the meantime, you can try working around it by adding the (undocumented) flag -implyavx512upperregs-, or just rolling back to an earlier VS version.