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
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
1584620 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #133265
1584545 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1584461 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #133308
1584442 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #130050

Summary

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

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

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions