Skip to content

[Android] System.Tests.RandomTests.Next_IntInt_Next_IntInt_AllValuesAreWithinRange failing on android-arm #112946

Open

Description

@simonrozsival

Build Information

Build: https://dev.azure.com/dnceng-public/public/_build/results?buildId=962825
Build error leg or test failing: System.Tests.RandomTests.Next_IntInt_Next_IntInt_AllValuesAreWithinRange

The test is consistently failing on android-arm (32-bit):

Last passing build: https://dev.azure.com/dnceng-public/public/_build/results?buildId=946422&view=results
First failing build: https://dev.azure.com/dnceng-public/public/_build/results?buildId=947194&view=results
Commit range: 02f99e5...91bbb32

Crash report:

                 02-25 14:01:16.594 30687 30711 I DOTNET  : 	[FAIL] System.Tests.RandomTests.Next_IntInt_Next_IntInt_AllValuesAreWithinRange(derived: False, seeded: True, min: -1, max: 2147483647)
                 02-25 14:01:16.594 30687 30711 I DOTNET  : Assert.InRange() Failure: Value not in range
                 02-25 14:01:16.594 30687 30711 I DOTNET  : Range:  (-1 - 2147483646)
                 02-25 14:01:16.594 30687 30711 I DOTNET  : Actual: -2

Error Message

Fill the error message using step by step known issues guidance.

{
  "ErrorMessage": [
    "[FAIL] System.Tests.RandomTests.Next_IntInt_Next_IntInt_AllValuesAreWithinRange",
    "Assert.InRange() Failure: Value not in range"
  ],
  "BuildRetry": false,
  "ExcludeConsoleLog": false
}

Known issue validation

Build: 🔎 https://dev.azure.com/dnceng-public/public/_build/results?buildId=962825
Error message validated: [[FAIL] System.Tests.RandomTests.Next_IntInt_Next_IntInt_AllValuesAreWithinRange Assert.InRange() Failure: Value not in range]
Result validation: ✅ Known issue matched with the provided build.
Validation performed at: 2/27/2025 9:09:33 AM UTC

Report

Build Definition Test Pull Request
975416 dotnet/runtime System.Runtime.Extensions.Tests.WorkItemExecution
974730 dotnet/runtime System.Runtime.Extensions.Tests.WorkItemExecution
973759 dotnet/runtime System.Runtime.Extensions.Tests.WorkItemExecution
973408 dotnet/runtime System.Runtime.Extensions.Tests.WorkItemExecution
973172 dotnet/runtime System.Runtime.Extensions.Tests.WorkItemExecution
973032 dotnet/runtime System.Runtime.Extensions.Tests.WorkItemExecution
972861 dotnet/runtime System.Runtime.Extensions.Tests.WorkItemExecution
972269 dotnet/runtime System.Runtime.Extensions.Tests.WorkItemExecution
971661 dotnet/runtime System.Runtime.Extensions.Tests.WorkItemExecution
971108 dotnet/runtime System.Runtime.Extensions.Tests.WorkItemExecution
970517 dotnet/runtime System.Runtime.Extensions.Tests.WorkItemExecution
969995 dotnet/runtime System.Runtime.Extensions.Tests.WorkItemExecution
969384 dotnet/runtime System.Runtime.Extensions.Tests.WorkItemExecution
968382 dotnet/runtime System.Runtime.Extensions.Tests.WorkItemExecution
967828 dotnet/runtime System.Runtime.Extensions.Tests.WorkItemExecution
967478 dotnet/runtime System.Runtime.Extensions.Tests.WorkItemExecution #113084
967177 dotnet/runtime System.Runtime.Extensions.Tests.WorkItemExecution
966785 dotnet/runtime System.Runtime.Extensions.Tests.WorkItemExecution
966619 dotnet/runtime System.Runtime.Extensions.Tests.WorkItemExecution
966484 dotnet/runtime System.Runtime.Extensions.Tests.WorkItemExecution
966316 dotnet/runtime System.Runtime.Extensions.Tests.WorkItemExecution
965974 dotnet/runtime System.Runtime.Extensions.Tests.WorkItemExecution
965468 dotnet/runtime System.Runtime.Extensions.Tests.WorkItemExecution
965092 dotnet/runtime System.Runtime.Extensions.Tests.WorkItemExecution
964581 dotnet/runtime System.Runtime.Extensions.Tests.WorkItemExecution
962825 dotnet/runtime System.Runtime.Extensions.Tests.WorkItemExecution

Summary

24-Hour Hit Count 7-Day Hit Count 1-Month Count
2 13 26

Report

Summary

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

Activity

  1. ghost added
    needs-area-labelAn area label is needed to ensure this gets routed to the appropriate area owners
    on Feb 26, 2025
  2. dotnet-policy-service commented on Feb 26, 2025

    @dotnet-policy-service
    Contributor

    Tagging subscribers to 'arch-android': @vitek-karas, @simonrozsival, @steveisok, @akoeplinger
    See info in area-owners.md if you want to be subscribed.

  3. dotnet-policy-service commented on Feb 26, 2025

    @dotnet-policy-service
    Contributor

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

  4. removed
    needs-area-labelAn area label is needed to ensure this gets routed to the appropriate area owners
    on Mar 3, 2025
  5. matouskozak commented on Apr 11, 2025

    @matouskozak
    Member

    Could it be caused by #112206 @tannergooding ?

  6. tannergooding commented on Apr 11, 2025

    @tannergooding
    Member

    @matouskozak, I wouldn't expect so without it also triggering for Mono on other platforms -or- there being some pre-existing Mono Arm32 bug that the change just happened to expose.

    All the PR does is handle the intrinsic and import it directly as the relevant IL opcode, there's not much room for it to have a mistake.

  7. added this to the 10.0.0 milestone on Jul 11, 2025
  8. removed
    untriagedNew issue has not been triaged by the area owner
    on Jul 11, 2025
  9. modified the milestones: 10.0.0, Future on Jul 14, 2025
  10. danmoseley commented on Mar 22, 2026

    @danmoseley
    Contributor

    Note

    This comment was generated by GitHub Copilot.

    Analysis

    Summary

    Random.Next(-1, int.MaxValue) returns -2 (below minimum) on Android ARM32 (Mono). Consistently failing since Feb 2025, 26+ CI hits.

    Root Cause

    PR #112206 (merged Feb 10, 2025 — within the bisect range) is the culprit. Here's the chain:

    1. CompatSeedImpl.Next(int, int) (used by new Random(42)) calls double.ConvertToIntegerNative<long>(sample * range) when range > int.MaxValue (which is the case for min=-1, max=int.MaxValue → range=2147483648).

    2. Before Have mono handle ConvertToIntegerNative for Double and Single #112206, ConvertToIntegerNative on Mono was guarded by #if !MONO and fell through to TInteger.CreateSaturating(value) — a managed implementation that works correctly.

    3. After Have mono handle ConvertToIntegerNative for Double and Single #112206, the guard was removed and Mono now intrinsifies ConvertToIntegerNative<long> as OP_FCONV_TO_I8 (JIT) / MINT_CONV_I8_R8 (interpreter).

    4. On ARM32 specifically, OP_FCONV_TO_I8 is emulated (see mini-arm.h: #define MONO_ARCH_EMULATE_FCONV_TO_I8 1). The emulation produces incorrect results — returning -1 for a positive double input, which then becomes -1 + (-1) = -2.

    5. This only hits ARM32 because ARM64/x64 have native 64-bit float→int instructions and don't use emulation.

    Tanner's comment aligns with this analysis

    He noted there would need to be "some pre-existing Mono Arm32 bug that the change just happened to expose." That's exactly what happened — the pre-existing bug is in Mono ARM32's OP_FCONV_TO_I8 emulation, and PR #112206 exposed it by routing ConvertToIntegerNative through that code path for the first time.

    Possible fixes

    1. Fix OP_FCONV_TO_I8 emulation on Mono ARM32 (proper fix)
    2. Guard the intrinsic — skip intrinsification of ConvertToIntegerNative<long> on ARM32 where emulation is needed, falling back to the managed CreateSaturating path
    3. Defer as ARM32 is lower priority.
  11. vitek-karas commented on Aug 7, 2026

    @vitek-karas
    Member

    This Known Build Error is being reviewed for closure because it appears inactive.

    Available successfully analyzed dotnet/runtime builds completed from September 14, 2023 through August 7, 2026 (UTC). No test failure in those builds was matched to this KBE.

    The last qualifying activity on this issue was a comment on March 22, 2026 at 04:31:12 UTC. No qualifying activity has occurred in the last three months.

    This issue will be closed after seven complete days unless one of the following happens:

    • a test failure is matched to this KBE;
    • a new comment is added to this issue;
    • a label or milestone on this issue is changed.

    If any of these happens, the issue will remain open and will be removed from this closure cycle.

    This comment was prepared with AI assistance.

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

Metadata

Metadata

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions