-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
We started observing intermittent CI failures on tests involving Base64 encoding in late June. This is recognized as a high-risk potential regression lurking in the .NET 10 release, and we need to find the root cause of this in time to resolve it before the .NET 10 RC1 release.
Here are the CI failures associated with this root cause:
- Cryptography.Tests: No PEM encoded data found #117163
2. WasmTestOnChrome-ST-System.Memory.Tests errors #117169 - System.Xml.Tests failing #117614
- System.Security.Cryptography.Rsa.Tests.RSAXml Test Suite Fails with Strings Differ/Containers Differ #117665
Both #117163 and #117169 were reported on June 30, which is the earliest recognized signal of this issue. As was noted in #117665:
That seems... bad?
-f6 ba 82 83 26 0c 39 91 1b 8b 5d b1 8a 0f f3 6a 78 d5 59 a8 0d 64 29 3d d0 0c 35 87 56 00 ...
+f4 0a 80 80 06 00 38 01 00 88 0d 80 88 0f c0 68 08 c0 58 08 00 64 09 00 d0 0c 00 84 06 00 ...
It's like something is clearing every other 6 bits?
- F4BA XOR F40A is 02B0: 0b0000_0010_1011_0000
- 8B5D XOR 880D is 0350: 0b0000_0011_0101_0000
Since base64 is a 6-bit map... I wonder if this is a base64 encoding problem.
This is happening across multiple architectures and operating systems, as well as across different physical machines.
- Machine a00DH2L running Windows-2016Server-10.0.14393-SP0
- Machine a009LPH running Linux-6.8.0-1030-azure-x86_64-with-glibc2.35
- Machine a009QWZ using docker image mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-22.04-helix-webassembly
@eiriktsarpalis conducted a preliminary investigation, reporting:
- The failing tests seem to all share a call to
System.Buffers.Text.Base64.EncodeToUtf8
, with that method producing corrupted data - Some of the tests exercise the API through the
System.Convert
APIs, which only use theBase64
class implementation if vectorization is available and applicable
runtime/src/libraries/System.Private.CoreLib/src/System/Convert.cs
Lines 2451 to 2454 in 9df2042
if (Vector128.IsHardwareAccelerated && !insertLineBreaks && bytes.Length >= Base64VectorizationLengthThreshold) { ToBase64CharsLargeNoLineBreaks(bytes, chars, charLengthRequired); } - The relevant implementation in System/Buffers/Text/Base64Helper/Base64EncoderHelper.cs hasn't been updated since October 2024
/cc @artl93 @jeffschwMSFT @marek-safar @lewing for visibility/awareness