Skip to content

[Mono][browser] Double Min/Max do not preserve NaN sign and payload #133311

Description

@lewing

Description

Mono on browser-wasm does not preserve the selected NaN sign/payload for double.Max and double.Min. The newly added shared generic-math cases from #133173 expose this on both Linux and Windows Chrome legs.

The assertion output renders both values as NaN, but AssertExtensions.Equal performs the required bitwise comparison and detects that the returned NaN differs from the expected operand.

Reproduction Steps

Run System.Runtime.Tests on browser-wasm with Mono and execute these generic-math cases:

double positiveNaN = BitConverter.Int64BitsToDouble(0x7FF8_0000_0000_0001);
double negativeNaN = BitConverter.Int64BitsToDouble(unchecked((long)0xFFF8_0000_0000_0001));

AssertExtensions.Equal(positiveNaN, NumberHelper<double>.Max(positiveNaN, -0.0));
AssertExtensions.Equal(negativeNaN, NumberHelper<double>.Max(-0.0, negativeNaN));
AssertExtensions.Equal(positiveNaN, NumberHelper<double>.Min(positiveNaN, -0.0));
AssertExtensions.Equal(negativeNaN, NumberHelper<double>.Min(-0.0, negativeNaN));

CI evidence from runtime build 1584442:

Expected behavior

double.Max and double.Min return the selected NaN operand with its sign and payload preserved, matching the API contract and other runtimes.

Actual behavior

All four cases fail bitwise equality on Mono browser-wasm:

[FAIL] System.Tests.DoubleTests_GenericMath.MaxTest(x: NaN, y: -0, expectedResult: NaN)
[FAIL] System.Tests.DoubleTests_GenericMath.MaxTest(x: -0, y: NaN, expectedResult: NaN)
[FAIL] System.Tests.DoubleTests_GenericMath.MinTest(x: NaN, y: -0, expectedResult: NaN)
[FAIL] System.Tests.DoubleTests_GenericMath.MinTest(x: -0, y: NaN, expectedResult: NaN)

Regression?

The failing inputs were added to shared test data by #133173. That PR fixed a CoreCLR SIMD constant-folding issue but did not change Mono lowering, so this appears to expose a pre-existing Mono correctness gap rather than introduce it.

Known Workarounds

Temporarily quarantine the affected DoubleTests_GenericMath.MaxTest and MinTest theories on Mono browser-wasm using this issue as the ActiveIssue reference.

Configuration

  • .NET 11 CI build from dotnet/runtime main/PR validation
  • Mono browser-wasm
  • Reproduces under headless Chrome on Linux x64 and Windows x64
  • Four failures out of 77,353 test cases in each affected work item

Other information

Related test expansion: #133173. The implementation should be checked for IEEE 754 minimum/maximum lowering that canonicalizes or otherwise changes a NaN operand rather than preserving its bits.

Build Information

Build: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1584442
Build error leg or test failing: browser-wasm Linux and Windows Release LibraryTests - WasmTestOnChrome-MONO-ST-System.Runtime.Tests
Pull request: #130050

KBE authoring guidance (ci-failure-scan)
  • Error Details is for readers. Paste the full exception, stack trace, or build error excerpt so the failure is understandable without opening the raw log.
  • Build Analysis parses only the single JSON block under Error Message.
  • ErrorPattern uses .NET Singleline | IgnoreCase | NonBacktracking matching with a 50ms-per-line timeout.
  • Keep the regex anchored, prefer [^\n]* over .*, and avoid catastrophic backtracking.
  • Set BuildRetry to true only for a clear infrastructure retry case. ExcludeConsoleLog disables Helix console-log scanning.

Error Details

[FAIL] System.Tests.DoubleTests_GenericMath.MaxTest(x: NaN, y: -0, expectedResult: NaN)
Assert.Equal() Failure: Values differ
Expected:                  NaN
Actual:                    NaN

[FAIL] System.Tests.DoubleTests_GenericMath.MaxTest(x: -0, y: NaN, expectedResult: NaN)
[FAIL] System.Tests.DoubleTests_GenericMath.MinTest(x: NaN, y: -0, expectedResult: NaN)
[FAIL] System.Tests.DoubleTests_GenericMath.MinTest(x: -0, y: NaN, expectedResult: NaN)

Error Message

{
  "ErrorMessage": "",
  "ErrorPattern": "^[^\\n]*\\[FAIL\\] System\\.Tests\\.DoubleTests_GenericMath\\.(Max|Min)Test\\(x: (NaN, y: -0|-0, y: NaN), expectedResult: NaN\\)",
  "BuildRetry": false,
  "ExcludeConsoleLog": false
}
Agentic workflow metadata (ci-failure-scan)

Workflow artifact: ci-failure-scan
Artifact kind: kbe-verification
Verified match count: 8 hits in failure.log

Report

Summary

24-Hour Hit Count 7-Day Hit Count 1-Month Count
0 0 0

Known issue validation

Build: 🔎 https://dev.azure.com/dnceng-public/public/_build/results?buildId=1584442
Result validation: ⚠️ Validation could not be done without an Azure DevOps build URL on the issue. Please add it to the "Build: 🔎" line.
Validation performed at: 9/5/2026 9:16:02 PM UTC

Note

This issue was generated with GitHub Copilot.

Known issue validation

Build: 🔎 https://dev.azure.com/dnceng-public/public/_build/results?buildId=1584442
Error message validated: [^[^\n]*\[FAIL\] System\.Tests\.DoubleTests_GenericMath\.(Max|Min)Test\(x: (NaN, y: -0|-0, y: NaN), expectedResult: NaN\)]
Result validation: ✅ Known issue matched with the provided build.
Validation performed at: 9/5/2026 9:24:25 PM UTC

Note

This issue was generated with GitHub Copilot.

Report

Build Repository Test Pull Request
1604117 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1604099 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1604019 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #134165
1604024 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1604027 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1603913 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #133389
1603853 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #134289
1603517 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1603483 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1603475 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #134164
1603480 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #134165
1603437 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #134163
1603463 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #134267
1603443 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1603190 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #133656
1603315 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1603249 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1603168 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #134229
1603138 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1603072 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #134225
1602949 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #133183
1602810 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1602809 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1602553 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1602613 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #134204
1602441 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1602319 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1602030 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1602019 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1601969 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1601744 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1601728 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #134162
1601751 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #134165
1601732 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #134163
1601556 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #133566
1601144 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1600993 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1600723 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #134126
1600746 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1599622 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1599619 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1598983 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #134047
1598915 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #134041
1598830 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #134038
1598821 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #134036
1598798 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #134034
1598566 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #133937
1598532 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1598267 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1598028 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1598025 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1597901 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #133972
1597825 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #133937
1597583 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #133951
1597543 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #133949
1597251 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #133937
1597255 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #133938
1596825 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1596716 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #133335
1596656 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1596318 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1596321 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1595902 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #133886
1594905 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #133389
1594314 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1594311 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1593809 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1593796 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #133769
1593588 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1593470 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1593288 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1592920 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1592917 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1592834 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #133699
1592634 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #133693
1592299 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1592296 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1592076 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #133664
1591710 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1591445 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1591180 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1591177 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1591096 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #133607
1591133 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #133611
1591048 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #133605
1590228 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #133566
1590019 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1589972 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1589610 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1589510 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1589218 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1588962 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1588952 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1588811 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #133477
1588604 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #133475
1588088 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1588122 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1584684 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #133285
1584677 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #133313
1584631 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #130050
Displaying 100 of 105 results

Summary

24-Hour Hit Count 7-Day Hit Count 1-Month Count
7 64 105

Known issue validation

Build: 🔎 https://dev.azure.com/dnceng-public/public/_build/results?buildId=1584442
Result validation: ⚠️ Validation could not be done without an Azure DevOps build URL on the issue. Please add it to the "Build: 🔎" line.
Validation performed at: 9/5/2026 9:16:02 PM UTC

Note

This issue was generated with GitHub Copilot.

Known issue validation

Build: 🔎 https://dev.azure.com/dnceng-public/public/_build/results?buildId=1584442
Error message validated: [^[^\n]*\[FAIL\] System\.Tests\.DoubleTests_GenericMath\.(Max|Min)Test\(x: (NaN, y: -0|-0, y: NaN), expectedResult: NaN\)]
Result validation: ✅ Known issue matched with the provided build.
Validation performed at: 9/5/2026 9:24:25 PM UTC

Note

This issue was generated with GitHub Copilot.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Known Build ErrorUse this to report build issues in the .NET Helix tabarch-wasmWebAssembly architecturearea-Codegen-Intrinsics-monoblocking-clean-ciBlocking PR or rolling runs of 'runtime' or 'runtime-extra-platforms'

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions