Failing Mono test when `Assembly.GetCallingAssembly()` is used

Open
#115,425 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
csharp, wasm
Domain
testing, tooling

Research direction

Start with the open PR 115345, the AssemblyTests.GetCallingAssemblyInCctor failure, and the Mono call paths get_executing and get_caller_no_reflection in src/mono/mono/metadata/icall.c. Compare the interpreted and IL Emit invocation paths, then run the failing interpreter and Wasm tests; done means the expected calling assembly is returned in those configurations without regressing the other path.

Written by the indexing model from the issue text.

Description

arch-wasm area-VM-reflection-mono

This is a placeholder for now for the open PR https://github.com/dotnet/runtime/pull/115345. This PR changes invoke so that it always goes through the IL Emit path unlike previously where it will go through the interpreted (c++ runtime) path for the first call to each method. Thus there is likely an underlying bug that needs to be fixed to account for both cases.

Note that if the switch "Switch.System.Reflection.ForceInterpretedInvoke" is set, then the interpreted path is aways used. This is not the case for the failing test platforms.

Also, the test class has a namespace that starts with "System.Reflection" and that namespace is checked for in Mono to avoid reflection frames. See get_executing and get_caller_no_reflection which may or may not be related.

The test output for the failing interpreter and Wasm tests look like this:

[22:01:08] info: [FAIL] System.Reflection.Tests.AssemblyTests.GetCallingAssemblyInCctor
[22:01:08] info: Assert.Equal() Failure: Values differ
[22:01:08] info: Expected: System.Reflection.Tests, Version=10.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
[22:01:08] info: Actual:   xunit.execution.dotnet, Version=2.9.2.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c
[22:01:08] info:    at System.Reflection.Tests.AssemblyTests.TestGetCallingAssemblyInCctor.Run()
[22:01:08] info:    at System.Object.InvokeStub_AssemblyTests.GetCallingAssemblyInCctor(IntPtr , Object )
[22:01:08] info:    at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

Failing configurations:

net10.0-browser-Release-wasm-Mono_Release-WasmTestOnChrome-(Windows.Server2025.Amd64.Open)windows.server2025.a
net10.0-browser-Release-wasm-Mono_Release-WasmTestOnChrome-(Windows.Amd64.Server2022.Open)windows.amd64.serve
net10.0-linux-Debug-x64-Mono_Interpreter_Debug-Ubuntu.2204.Amd64.Open
net10.0-linux-Debug-x64-Mono_Interpreter_Debug-(Debian.13.Amd64.Open)Ubuntu.2204.Amd64.Open@mcr.microsoft.com/do
net10.0-linux-Debug-x64-Mono_Interpreter_Debug-(Centos.10.Amd64.Open)Ubuntu.2204.Amd64.Open@mcr.microsoft.com/d
net10.0-browser-Release-wasm-Mono_Release-WasmTestOnFirefox-(Ubuntu.2204.Amd64)Ubuntu.2204.Amd64.Open@mcr.micro
net10.0-browser-Release-wasm-Mono_Release-WasmTestOnChrome-(Ubuntu.2204.Amd64)Ubuntu.2204.Amd64.Open@mcr.m
net10.0-browser-Release-wasm-Mono_Release-WasmTestOnChrome-(Ubuntu.2204.Amd64)Ubuntu.2204.Amd64.Open@mcr.mic
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/runtime

All issues in dotnet/runtime

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.