Skip to content

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

Closed

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
1634262 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #135730
1633767 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1633691 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1633467 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #135409
1633355 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1632962 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1632805 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1632616 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #135643
1632652 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1632413 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1632410 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1632222 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #135476
1631564 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #134773
1630558 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1630555 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1630261 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #135536
1629372 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #135476
1628946 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1628879 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1628720 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1628541 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #135334
1628467 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1628470 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1627615 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #135409
1626981 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1626978 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1626493 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1626490 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1626401 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #135338
1626189 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1626192 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #135334
1625681 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1625839 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #134393
1625742 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1625609 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #135315
1625245 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1625089 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #135282
1625248 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1625044 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #135281
1625037 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #135280
1624492 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1624401 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #134393
1624228 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1624231 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1623165 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #135198
1623130 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #133337
1622081 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1621713 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1621670 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1621475 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1621227 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1620545 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1620429 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1620034 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1620212 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest #134484
1620029 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1619118 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest #135000
1619096 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1618934 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1618762 dotnet/runtime System.Tests.DoubleTests_GenericMath.MinTest
1618254 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest
1618251 dotnet/runtime System.Tests.DoubleTests_GenericMath.MaxTest

Summary

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

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

  1. dotnet-policy-service commented on Sep 5, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
    See info in area-owners.md if you want to be subscribed.

  2. dotnet-policy-service commented on Sep 5, 2026

    @dotnet-policy-service
    Contributor

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

  3. added
    Known Build ErrorUse this to report build issues in the .NET Helix tab
    and removed
    untriagedNew issue has not been triaged by the area owner
    on Sep 5, 2026
  4. added this to the 12.0.0 milestone on Sep 11, 2026
  5. agocke commented on Oct 14, 2026

    @agocke
    Member

    Fixed by 20f7be9

  6. added
    disabled-testThe test is disabled in source code against the issue
    and removed
    blocking-clean-ciBlocking PR or rolling runs of 'runtime' or 'runtime-extra-platforms'
    on Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions