Repository navigation
Closed
Description
Description
This happens in our test suite:
Stack overflow.
Repeated 7349 times:
--------------------------------
at System.Runtime.InteropServices.DynamicInterfaceCastableHelpers.GetInterfaceImplementation(System.Runtime.InteropServices.IDynamicInterfaceCastable, System.RuntimeType)
--------------------------------
at Xamarin.Tests.AvailabilityExtensions.IsAvailable(System.Collections.Generic.IEnumerable`1<System.ValueTuple`3<System.Runtime.Versioning.OSPlatformAttribute,Xamarin.Utils.ApplePlatform,System.Version>>, Xamarin.Tests.PlatformInfo, Xamarin.Utils.ApplePlatform)
at Xamarin.Tests.AvailabilityExtensions.IsAvailable(System.Collections.Generic.IEnumerable`1<System.Runtime.Versioning.OSPlatformAttribute>, Xamarin.Tests.PlatformInfo)
at Xamarin.Tests.AvailabilityExtensions.IsAvailable(System.Reflection.ICustomAttributeProvider, Xamarin.Tests.PlatformInfo)
at Xamarin.Tests.AvailabilityExtensions.IsAvailableOnHostPlatform(System.Reflection.ICustomAttributeProvider)
at Introspection.ApiBaseTest.SkipDueToAttribute(System.Reflection.MemberInfo)
at Introspection.ApiCMAttachmentTest.Skip(System.Type)
[...]
Reproduction Steps
Needs Xcode 26.1.1 installed in /Applications/Xcode_26.1.1.app.
$ git clone --recursive https://github.com/dotnet/macios
$ cd macios
$ git checkout dev/rolf/net11.0-coreclr
$ git reset --hard 0129a5d735b6ff4947c354e7ffa6233c6fa4a2c9
$ ./configure --disable-all-platforms --enable-maccatalyst
$ make all -j8
$ make install -j8
$ make build run-bare TEST_VARIATION=coreclr RID=maccatalyst-x64 -C tests/introspection/dotnet/MacCatalystExpected behavior
Successful test execution.
Actual behavior
Details
$ make build run-bare TEST_VARIATION=coreclr RID=maccatalyst-x64
Found ccache on the system, enabling it
Detected the macios-adr repository, automatically enabled the Xamarin build
2025-11-14 16:16:43.642 introspection[86919:4310425] Microsoft.MacCatalyst: Invalid IDE Port: -1
2025-11-14 16:16:47.496 introspection[86919:4309880] Queuing test loading on background thread
2025-11-14 16:16:47.503 introspection[86919:4310554] Loading tests on background thread
2025-11-14 16:16:47.580 introspection[86919:4310554] Loaded tests on background thread, queuing UI update on main thead
2025-11-14 16:16:47.907 introspection[86919:4309880] Updating UI on main thead
2025-11-14 16:16:48.089 introspection[86919:4309880] AutoRun ()
2025-11-14 16:16:48.089 introspection[86919:4309880] AutoRun (): queuing test run on main thread
2025-11-14 16:16:48.095 introspection[86919:4309880] AutoRun (): running tests on main thread
2025-11-14 16:16:48.129 introspection[86919:4309880] [Runner executing: Run Everything]
2025-11-14 16:16:48.129 introspection[86919:4309880] [MonoTouch Version: 26.0.11017]
2025-11-14 16:16:48.130 introspection[86919:4309880] [Assembly: Microsoft.MacCatalyst.dll (64 bits)]
2025-11-14 16:16:48.130 introspection[86919:4309880] [GC: sgen]
2025-11-14 16:16:48.130 introspection[86919:4309880] [iPad: iPadOS v18.7]
2025-11-14 16:16:48.130 introspection[86919:4309880] [Device Name: iPad]
2025-11-14 16:16:48.131 introspection[86919:4309880] [Device UDID: unknown]
2025-11-14 16:16:48.158 introspection[86919:4309880] [Device Locale: en_US@rg=eszzzz]
2025-11-14 16:16:48.160 introspection[86919:4309880] [Device Date/Time: 11/14/2025 4:16:48 PM]
2025-11-14 16:16:48.161 introspection[86919:4309880] [Bundle: com.xamarin.introspection]
2025-11-14 16:16:48.171 introspection[86919:4310580] introspection
2025-11-14 16:16:48.175 introspection[86919:4310580] Introspection
2025-11-14 16:16:48.175 introspection[86919:4310580] Introspection.ApiCMAttachmentTest
2025-11-14 16:16:48.298 introspection[86919:4310580] [PASS] CheckAttachments
Stack overflow.
Repeated 59038 times:
--------------------------------
at System.Runtime.InteropServices.DynamicInterfaceCastableHelpers.GetInterfaceImplementation(System.Runtime.InteropServices.IDynamicInterfaceCastable, System.RuntimeType)
--------------------------------
at Xamarin.Tests.AvailabilityExtensions.IsAvailable(System.Collections.Generic.IEnumerable`1<System.ValueTuple`3<System.Runtime.Versioning.OSPlatformAttribute,Xamarin.Utils.ApplePlatform,System.Version>>, Xamarin.Tests.PlatformInfo, Xamarin.Utils.ApplePlatform)
at Xamarin.Tests.AvailabilityExtensions.IsAvailable(System.Collections.Generic.IEnumerable`1<System.Runtime.Versioning.OSPlatformAttribute>, Xamarin.Tests.PlatformInfo)
at Xamarin.Tests.AvailabilityExtensions.IsAvailable(System.Reflection.ICustomAttributeProvider, Xamarin.Tests.PlatformInfo)
at Xamarin.Tests.AvailabilityExtensions.IsAvailableOnHostPlatform(System.Reflection.ICustomAttributeProvider)
at Introspection.ApiBaseTest.SkipDueToAttribute(System.Reflection.MemberInfo)
at Introspection.ApiCMAttachmentTest.Skip(System.Type)
at Introspection.ApiCMAttachmentTest.CheckFailAttachments()
at System.RuntimeMethodHandle.InvokeMethod(System.Object, Void**, System.Signature, Boolean)
at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(System.Object, IntPtr*)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(System.Object, System.Reflection.BindingFlags)
at System.Reflection.RuntimeMethodInfo.Invoke(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)
at System.Reflection.MethodBase.Invoke(System.Object, System.Object[])
at NUnit.Framework.Internal.Reflect.InvokeMethod(System.Reflection.MethodInfo, System.Object, System.Object[])
at NUnit.Framework.Internal.MethodWrapper.Invoke(System.Object, System.Object[])
at NUnit.Framework.Internal.Commands.TestMethodCommand.InvokeTestMethod(NUnit.Framework.Internal.TestExecutionContext)
at NUnit.Framework.Internal.Commands.TestMethodCommand.RunTestMethod(NUnit.Framework.Internal.TestExecutionContext)
at NUnit.Framework.Internal.Commands.TestMethodCommand.Execute(NUnit.Framework.Internal.TestExecutionContext)
at NUnit.Framework.Internal.Execution.SimpleWorkItem.PerformWork()
at NUnit.Framework.Internal.Execution.WorkItem.RunOnCurrentThread()
at NUnit.Framework.Internal.Execution.WorkItem.Execute()
at NUnit.Framework.Internal.Execution.MainThreadWorkItemDispatcher.Dispatch(NUnit.Framework.Internal.Execution.WorkItem)
at NUnit.Framework.Internal.Execution.CompositeWorkItem.RunChildren()
at NUnit.Framework.Internal.Execution.CompositeWorkItem.PerformWork()
at NUnit.Framework.Internal.Execution.WorkItem.RunOnCurrentThread()
at NUnit.Framework.Internal.Execution.WorkItem.Execute()
at NUnit.Framework.Internal.Execution.MainThreadWorkItemDispatcher.Dispatch(NUnit.Framework.Internal.Execution.WorkItem)
at NUnit.Framework.Internal.Execution.CompositeWorkItem.RunChildren()
at NUnit.Framework.Internal.Execution.CompositeWorkItem.PerformWork()
at NUnit.Framework.Internal.Execution.WorkItem.RunOnCurrentThread()
at NUnit.Framework.Internal.Execution.WorkItem.Execute()
at NUnit.Framework.Internal.Execution.MainThreadWorkItemDispatcher.Dispatch(NUnit.Framework.Internal.Execution.WorkItem)
at NUnit.Framework.Internal.Execution.CompositeWorkItem.RunChildren()
at NUnit.Framework.Internal.Execution.CompositeWorkItem.PerformWork()
at NUnit.Framework.Internal.Execution.WorkItem.RunOnCurrentThread()
at NUnit.Framework.Internal.Execution.WorkItem.Execute()
at NUnit.Framework.Internal.Execution.MainThreadWorkItemDispatcher.Dispatch(NUnit.Framework.Internal.Execution.WorkItem)
at NUnit.Framework.Internal.Execution.MainThreadWorkItemDispatcher.Start(NUnit.Framework.Internal.Execution.WorkItem)
at NUnit.Framework.Api.NUnitTestAssemblyRunner.StartRun(NUnit.Framework.Interfaces.ITestListener)
at NUnit.Framework.Api.NUnitTestAssemblyRunner+<>c__DisplayClass38_0.<RunAsync>b__0()
at NUnit.Framework.Api.NUnitTestAssemblyRunner.WrapInNUnitCallContext(System.Action)
at NUnit.Framework.Api.NUnitTestAssemblyRunner.RunAsync(NUnit.Framework.Interfaces.ITestListener, NUnit.Framework.Interfaces.ITestFilter)
at NUnit.Framework.Api.NUnitTestAssemblyRunner.Run(NUnit.Framework.Interfaces.ITestListener, NUnit.Framework.Interfaces.ITestFilter)
at MonoTouch.NUnit.UI.BaseTouchRunner.Run(NUnit.Framework.Internal.Test)
at MonoTouch.NUnit.UI.BaseTouchRunner.Run()
at MonoTouch.NUnit.UI.BaseTouchRunner.<AutoRun>b__49_0()
at MonoTouch.NUnit.UI.TouchRunner+<>c__DisplayClass19_0.<ExecuteOnMainThread>b__0()
at Foundation.NSAsyncActionDispatcher.Apply()
at System.RuntimeMethodHandle.InvokeMethod(System.Object, Void**, System.Signature, Boolean)
at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(System.Object, IntPtr*)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(System.Object, System.Reflection.BindingFlags)
at System.Reflection.RuntimeMethodInfo.Invoke(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)
at ObjCRuntime.Runtime.InvokeMethod(System.Reflection.MethodBase, System.Object, IntPtr)
at ObjCRuntime.Runtime.InvokeMethod(MonoObject*, MonoObject*, IntPtr)
at ObjCRuntime.Runtime.bridge_runtime_invoke_method(MonoObject*, MonoObject*, IntPtr, IntPtr*)
at UIKit.UIApplication.UIApplicationMain(Int32, System.String[], IntPtr, IntPtr)
at UIKit.UIApplication.Main(System.String[], System.Type, System.Type)
at MainClass.Main(System.String[])
make: *** [run-bare] Abort trap: 6
Regression?
No
Known Workarounds
No response
Configuration
No response
Other information
No response
Activity
dotnet-policy-service commentedon Nov 14, 2025
Tagging subscribers to this area: @BrzVlad, @janvorli, @kg
See info in area-owners.md if you want to be subscribed.
rolfbjarne commentedon Nov 14, 2025
I'm not sure if this is the same bug or not, but our other test suite also crashes, with something that looks like stack overflows: https://gist.github.com/rolfbjarne/fc397ffd355ecfc7f6c89fa48a4e9924
Repro is the same, except the last line, which is:
Details
BrzVlad commentedon Nov 17, 2025
cc @kotlarmilos
kotlarmilos commentedon Nov 19, 2025
This issue looks like an infinite recursion in interface resolution when casting an object that implements IDynamicInterfaceCastable to IDisposable. It begins in GetInterfaceImplementation, which triggers interface lookup, re-enters the interpreter, and attempts to resolve the same interface method again.
The first argument to GetInterfaceImplementation (rdi) was the object at 0x000000018a50d5e0, with its MethodTable at 0x000000018a50cf70. This is the class implementing IDynamicInterfaceCastable. The second argument (rsi) was a TypeHandle with value 0x000000010ac579b8, which is the MethodTable for IDisposable. The MethodDesc being resolved uses slot 0x0001, which matches Dispose().
The MethodDesc captured from the interpreter frame encodes the same IDisposable MethodTable in its header and shows slot 0x0001. This shows that the interpreter is trying to resolve IDisposable.Dispose() on the same object. When interpreter enters the managed GetInterfaceImplementation, that method causes another lookup for the same interface and method on the same instance, which re-enters the interpreter at the same point.
kotlarmilos commentedon Nov 20, 2025
I’m hitting the following assert in the debug configuration. I suspect it’s the same root cause as in the release configuration since it is failing around the same test. I think it is coming from open virtual delegates where it takes wrong stack slot and ends up passing a wrong MethodTable into GetMethodDescOfVirtualizedCode.
If I skip this assert, it later fails with:
kotlarmilos commentedon Nov 21, 2025
The interpreter hits a MethodTable::SanityCheck assert in debug because the MethodTable for the this argument in a virtual call is corrupted when MethodDescOfVirtualizedCode executes. The failure occurs at the point where the method table is fetched:
In release, the same issue appears later inside GetMethodDescForInterfaceMethodAndServer, which is expected since both paths depend on the same invalid this pointer.
The corrupted object has an invalid component size, indicating that the pointer being treated as an object is not a valid MethodTable:
The last logged virtual call shows that the this argument is in the arg slot at offset 240:
Tracing that slot leads to Xamarin.Tests.AvailabilityExtensions:IsAvailable(): https://gist.github.com/kotlarmilos/63857d07d9390ead5732e7a7921f7dc5
The same slot is reused several times for different locals and virtual call arguments. I expanded initlocals to zero reused slots and added GCPROTECT around GetMethodDescOfVirtualizedCode, but the error still exists. This indicates that the pointer is already invalid before callvirt runs and is not caused by GC movement.
At this point my reasoning is that the interpreter writes a non-object value into the arg slot, either by emitting incorrect object reference for a virtual call or by pushing a value-type or stale value that is interpreted as an object pointer in the virtcall path.
kotlarmilos commentedon Nov 21, 2025
Desktop repro on x64 debug: https://gist.github.com/kotlarmilos/bc04e7b817f2643612092a76d9399858
kotlarmilos commentedon Nov 24, 2025
I managed to run the code on macOS x64 under rosetta. The issue appears when two consecutive INTOP_CALLVIRT execute with the same callArgsOffset (112) and returnOffset (64). In the first virtcall the this argument points to a valid
System.Linq.Enumerable+ArraySelectIterator'2[[System.ValueTuple'3instance. After the first call, INTOP_RET_VT performs a memmove that overwrites the memory slot that previously held the valid this pointer:Then the second CALLVIRT takes an invalid pointer as its this argument. This reproduces only when the iterator returns a value-type tuple on x64.
Fix interpreter Unix x64 call stub generator (dotnet#121942)