Skip to content

[browser][CoreCLR][R2R] Ref-like reflection invoke throws IndexOutOfRangeException #134262

Description

@lewing

Description

Two reflection invoke test variants produce IndexOutOfRangeException instead of the expected NotSupportedException under trimmed browser-Wasm CoreCLR ReadyToRun.

Affected test:

System.Reflection.Tests.InvokeWithRefLikeArgs.MethodTakesRefToRefStructAsArg_ThrowsNSE

The failure occurs in both System.Runtime.ReflectionInvokeInterpreted.Tests and System.Runtime.ReflectionInvokeEmit.Tests.

Reproduction Steps

Build and run either affected test project for browser-Wasm CoreCLR with:

TestWasmReadyToRun=true
EnableAggressiveTrimming=true
RuntimeFlavor=CoreCLR
Configuration=Release

The failures reproduced in PR #133656, Azure DevOps build 1603190, Helix job 3158c862-61f5-4cf9-bb24-6ecdf2cfe895, work items WasmTestOnChrome-CLR-ST-Batch-10 and Batch-12.

Expected behavior

MethodInfo.Invoke rejects the by-ref-like argument shape with NotSupportedException.

Actual behavior

Assert.Throws() Failure: Exception type was not an exact match
Expected: typeof(System.NotSupportedException)
Actual:   typeof(System.IndexOutOfRangeException)
---- System.IndexOutOfRangeException: Index was outside the bounds of the array.

Regression?

Unknown. The same test has existing platform-specific exclusions for Mono and Apple mobile, but this browser CoreCLR ReadyToRun configuration is newly enabled.

Known Workarounds

Temporarily exclude this exact test method only when PlatformDetection.IsWasmReadyToRun is true. Interpreter and other-platform coverage remains enabled.

Configuration

Browser-Wasm CoreCLR Release, aggressively trimmed per-app ReadyToRun, Linux Helix host, Chrome 153.

Other information

Re-enable when both reflection invocation implementations return the documented exception under Wasm ReadyToRun.

Note

This issue was generated with GitHub Copilot assistance and reviewed as part of the #133193 bring-up.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    arch-wasmWebAssembly architecturearea-System.Reflectionos-browserBrowser variant of arch-wasmuntriagedNew issue has not been triaged by the area owner

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions