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
1613330 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #134702
1612733 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1613145 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1612511 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1612508 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1611136 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #134607
1611072 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #134484
1610988 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #134595
1610995 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #134596
1610890 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #134593
1610090 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #134393
1609955 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1609928 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1609313 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1609316 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1609324 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #134484
1608507 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #134501
1608344 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #134484
1608145 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1608148 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1608139 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1608142 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1607603 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #134443
1607543 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #134442
1607380 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1607279 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1606964 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1606967 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1606640 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #134395
1606616 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1606570 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #134393
1606540 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1606021 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1606183 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1606205 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #134374
1606027 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #134370
1606028 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #134369
1605978 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #134365
1605639 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1605355 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1605236 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1605089 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #134331
1604907 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1604977 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #134328
1604910 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1604887 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #134326
1604585 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #133335
1604366 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1604348 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1604301 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1604286 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1604239 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1604236 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1604225 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #134310
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
Displaying 100 of 159 results

Summary

24-Hour Hit Count 7-Day Hit Count 1-Month Count
3 61 159

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