runtime icon indicating copy to clipboard operation
runtime copied to clipboard

Test failure: System.Text.Json.SourceGeneration.Tests.NumberHandlingTests_Default.Number_AsRootType_RoundTrip

Open v-wenyuxu opened this issue 1 year ago • 6 comments

Failed in: runtime-coreclr libraries-jitstress-random 20240824.1

Failed tests:

net9.0-windows-Release-x64-jitstress_random_1-Windows.10.Amd64.Open
    - System.Text.Json.SourceGeneration.Tests.NumberHandlingTests_Default.Number_AsRootType_RoundTrip
    - System.Text.Json.SourceGeneration.Tests.NumberHandlingTests_Default.EscapingTest
    - System.Text.Json.SourceGeneration.Tests.NumberHandlingTests_Default.Number_AsCollectionElement_RoundTrip
    - System.Text.Json.SourceGeneration.Tests.NumberHandlingTests_Metadata.Number_AsCollectionElement_RoundTrip
    - System.Text.Json.SourceGeneration.Tests.NumberHandlingTests_Metadata.EscapingTest
    - System.Text.Json.SourceGeneration.Tests.NumberHandlingTests_Metadata.Number_AsRootType_RoundTrip

Error message:

 Assert.Equal() Failure: Values differ
Expected: 9223372036854775808
Actual:   0

Stack trace:

   at System.Text.Json.Serialization.Tests.NumberHandlingTests.PerformAsRootTypeSerialization[T](T number, String jsonWithNumberAsNumber, String jsonWithNumberAsString) in /_/src/libraries/System.Text.Json/tests/Common/NumberHandlingTests.cs:line 116
   at System.Text.Json.Serialization.Tests.NumberHandlingTests.RunAsRootTypeTest[T](List`1 numbers) in /_/src/libraries/System.Text.Json/tests/Common/NumberHandlingTests.cs:line 96
   at System.Text.Json.Serialization.Tests.NumberHandlingTests.Number_AsRootType_RoundTrip() in /_/src/libraries/System.Text.Json/tests/Common/NumberHandlingTests.cs:line 67
--- End of stack trace from previous location ---

v-wenyuxu avatar Aug 26 '24 01:08 v-wenyuxu

Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis See info in area-owners.md if you want to be subscribed.

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch See info in area-owners.md if you want to be subscribed.

set DOTNET_TieredCompilation=0
set DOTNET_JitStress=2cd

jakobbotsch avatar Aug 26 '24 12:08 jakobbotsch

cc @dotnet/jit-contrib, looks like bad codegen. Perhaps we should target .NET 10 until we determine this can be hit in non-stress scenarios?

amanasifkhalid avatar Aug 26 '24 15:08 amanasifkhalid

After some bisections the minimal set of env vars to repro seems to be:

DOTNET_JitStressModeNames      STRESS_LEGACY_INLINE STRESS_PROMOTE_FEWER_STRUCTS
DOTNET_JitStressOnly           System.Text.Json.Serialization.Tests.NumberHandlingTests:GetNumberAsString[System.Int128](System.Int128)
DOTNET_TieredCompilation       0

jakobbotsch avatar Aug 27 '24 16:08 jakobbotsch

This looks like a bug in object stack allocation. Specifically, it assumes that the payload of StackAllocatedBox<Int128> is at +8 offset, but due to alignment it actually is at +16. Thus we end up storing data in padding that promotion does not preserve.

jakobbotsch avatar Aug 27 '24 17:08 jakobbotsch