Repository navigation
Description
Note
This issue write-up was drafted with assistance from GitHub Copilot CLI.
Description
System.Runtime.Tests crashes on launch on iOS-arm64 device builds (iOS 26.1) before any test body executes. The dying thread is an xunit discovery worker, and the immediate cause is an indirect branch to PC = 0 from the interpreter, dispatched out of the new System.Reflection.MethodBaseInvoker.InvokeWithOneArg fast path.
The Apple corpse report shows EXC_BAD_ACCESS / KERN_PROTECTION_FAILURE at 0x0 annotated by the kernel as CODESIGNING / Invalid Page and turned into SIGKILL via cs_invalid_page (because the process has CS_KILL set, as is normal for app-bundle launches on iOS device). That kernel surface is a consequence of the runtime branching to a null function pointer; it is not itself the bug.
Crash signature
.ips excerpt for the dying thread:
Exception Type: EXC_BAD_ACCESS (SIGKILL - CODESIGNING)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000000
Exception Codes: 0x0000000000000002, 0x0000000000000000
Termination Reason: CODESIGNING 2 Invalid Page
Triggered by Thread: 23
Image base of the crashing R2R image in the dump: 0x170d24000 for System.Runtime.Tests.r2r.dylib, UUID 964F3601-1490-3604-88B0-309EFC23E6B7.
Symbolicated stack
Demangled against a locally-rebuilt R2R dylib whose Mach-O UUID is byte-identical to the helix one (see "Reproduction" below):
# image / offset frame
--- ----------------------------------------------------- -----------------------------------------------------
0 ?+0x0 PC = 0 (null instruction fetch)
1 libcoreclr.dylib+0x2ba8b8 InterpExecMethod
2 libcoreclr.dylib+0x216328 ExecuteInterpretedMethod
3 libcoreclr.dylib+0x39d980 InterpreterStubRetI8
4 libcoreclr.dylib+0x39ef68 CallJittedMethodRetI8 <- jumps to null target
5 libcoreclr.dylib+0x2b5be0 InvokeCalliStub(CalliStubParam*)
6 libcoreclr.dylib+0x2b9c68 InterpExecMethod
7 libcoreclr.dylib+0x216328 ExecuteInterpretedMethod
8 libcoreclr.dylib+0x39d980 InterpreterStubRetI8 <- R2R → interp transition
9 System.Runtime.Tests.r2r.dylib+0xb74324 System.Reflection.MethodBaseInvoker.InvokeWithOneArg + 0x234
10 System.Runtime.Tests.r2r.dylib+0xb8d3dc System.Reflection.RuntimeMethodInfo.Invoke + 0x20c
11 System.Runtime.Tests.r2r.dylib+0x1c778ec Xunit.Sdk.Reflector.ConvertArgument + 0x42c
12 System.Runtime.Tests.r2r.dylib+0x1c90c88 Xunit.Sdk.ReflectionAttributeInfo.<Convert>d__11.MoveNext + 0x238
13 System.Runtime.Tests.r2r.dylib+0x2f80b78 System.Collections.Generic.List<__Canon>..ctor(IEnumerable<__Canon>) + 0xe8
14 System.Runtime.Tests.r2r.dylib+0x3605d1c System.Linq.Enumerable.ToList<__Canon> + 0x9c
15 System.Runtime.Tests.r2r.dylib+0x162118 Microsoft.DotNet.XUnitExtensions.ConditionalTheoryDiscoverer.CreateTestCasesForTheory + 0x48
16 System.Runtime.Tests.r2r.dylib+0x1c6f39c Xunit.Sdk.TheoryDiscoverer.Discover + 0xfbc
17 System.Runtime.Tests.r2r.dylib+0x1c71890 Xunit.Sdk.XunitTestFrameworkDiscoverer.FindTestsForMethod + 0x320
18 System.Runtime.Tests.r2r.dylib+0x1c71d98 Xunit.Sdk.XunitTestFrameworkDiscoverer.FindTestsForType + 0x108
19 System.Runtime.Tests.r2r.dylib+0x1c6aa6c Xunit.Sdk.TestFrameworkDiscoverer.FindTestsForTypeAndWrapExceptions + 0x2c
20 System.Runtime.Tests.r2r.dylib+0x1c8fddc Xunit.Sdk.TestFrameworkDiscoverer.<>c__DisplayClass26_0.<Find>b__0 + 0x13c
21 System.Runtime.Tests.r2r.dylib+0x1c92cb0 Xunit.Sdk.XunitWorkerThread.<>c.<QueueUserWorkItem>b__5_0 + 0x30
22 System.Runtime.Tests.r2r.dylib+0xa888dc System.Threading.ExecutionContext.RunInternal + 0xac
23 System.Runtime.Tests.r2r.dylib+0xab07dc System.Threading.Tasks.Task.ExecuteWithThreadLocal + 0x30c
24 System.Runtime.Tests.r2r.dylib+0xa7e430 System.Threading.Thread.StartCallback + 0xd0
25-31 libcoreclr / libsystem_pthread (UnmanagedCallersOnly + thread bootstrap)
What the thread is doing, top-down: an xunit discovery worker is materializing the data-row list of a [Theory] (via Microsoft.DotNet.XUnitExtensions.ConditionalTheoryDiscoverer); for each data row it converts an attribute argument to the parameter type via Reflector.ConvertArgument, which goes through RuntimeMethodInfo.Invoke → MethodBaseInvoker.InvokeWithOneArg. That fast path transitions out of R2R into the interpreter (frame 8: InterpreterStubRetI8), the interpreter executes some IL, hits a calli whose target stub address is 0 (frames 5/4/3/2/1 — InvokeCalliStub → CallJittedMethodRetI8), and the indirect branch lands at PC = 0.
The crash happens roughly 424 ms after launch, before any test body runs — this is fully inside test discovery.
Why the kernel surface is SIGKILL / CODESIGNING, not SIGSEGV
iOS app-bundle processes launched via SpringBoard / RunningBoard / devicectl run with codeSigningFlags = 0x22002305 = CS_RUNTIME | CS_LINKER_SIGNED | CS_REQUIRE_LV | CS_HARD | CS_KILL | CS_GET_TASK_ALLOW | CS_VALID. With CS_KILL set, an instruction-fetch from an unsigned/unmapped page goes through cs_invalid_page and is delivered as psignal_sigkill_with_reason(OS_REASON_CODESIGNING, code 2 = "Invalid Page") — which is uncatchable (no signal is delivered to userspace). That's why no runtime signal handler — including any in-proc crash reporter — sees this fault on device. On the iOS simulator the same code path produces a normal catchable SIGSEGV with pc = 0.
| Fault | Simulator | Device |
|---|---|---|
| Data load/store of null page | SIGSEGV |
SIGSEGV |
| Indirect branch to null / unsigned page | SIGSEGV |
SIGKILL (CS_KILL) |
| Jetsam / watchdog / sandbox | SIGKILL |
SIGKILL |
This bug lands in the second row.
Reproduction
- AzDO build
1409391, legbuild_ios_arm64_Release_AllSubsets_CoreCLR_Smoke - Helix job
90f8c63f-753a-4dae-938d-3def4e5c5af9, work itemSystem.Runtime.Tests, queueosx.15.amd64.iphone.open, machineDNCENGOSX125, device00008030-000174882E23402E, iOS 26.1 (build 23B85) - Apple corpse report:
System.Runtime.Tests-2026-05-05-173657.ips - Build settings (from
build-apple-app.shin the work-item payload):TargetOS=ios,TargetArchitecture=arm64,Configuration=ReleasePublishReadyToRun=true,PublishReadyToRunComposite=true,PublishReadyToRunContainerFormat=machoUseMonoRuntime=false,UseNativeAOTRuntime=false,RunAOTCompilation=(empty),MonoForceInterpreter=(empty)StripSymbols=true
Local reproduction-quality validation
To make sure offsets in the .ips could be symbolicated unambiguously, the helix work-item payload + the matching microsoft.netcore.app.runtime.ios-arm64 and crossgen2 correlation payloads were pulled from helix.dot.net / Azure blob storage, the helix correlation tree was reconstructed locally, and the same dotnet msbuild .../ProxyProjectForAOTOnHelix.proj /t:_RunR2RCompilationOnHelix … was run with the same SDK (11.0.100-preview.3.26170.106).
Result: locally rebuilt System.Runtime.Tests.r2r.dylib has UUID 964F3601-1490-3604-88B0-309EFC23E6B7 — byte-identical to the dylib that crashed in the failing helix workitem. R2R composite compilation is fully deterministic given the same SDK + crossgen2 + inputs, so the corresponding .dSYM/ resolves the offsets to managed method names with no ambiguity. The stack above was produced that way (the helix-shipped dylib is StripSymbols=true, but the local rebuild produces a usable .dSYM/ on the side).
Suggested simulator repro
This should reproduce on iOS-arm64 simulator (it's the same R2R image and the same managed code path), and would surface as a catchable SIGSEGV with pc = 0 and identical managed frames — much friendlier to attach lldb to. Worth confirming whether MonoForceInterpreter= (empty), RunAOTCompilation= (empty), composite-R2R configuration is enough, or whether DOTNET_TieredCompilation=0 is needed to keep the interpreter on the path during discovery.
Hypotheses for the runtime bug
(Ordered by rough plausibility; full triage owners are area-CodeGen-Interpreter-coreclr / area-System.Reflection.)
- Stale or never-initialized
CalliStubParam.TargetwhenMethodBaseInvoker.InvokeWithOneArg(managed in System.Private.CoreLib) sets up thecalliinto a converter delegate / method-table slot. The fast-path landed in 9.0/10.0 with the new managed reflection invoker and may not exercise the same lazy slot fixup that the olderCallStubGeneratorpaths do. - Race between
CallStubHeadergeneration and the calli dispatch (cf. [clr-interp] Fix logic around interpreter stub startup where the CallStubHeader may not be generated due to a race #120952 — same area, different symptom: stub not yet generated when the dispatch fires). - Missing IL-stub fallback when
FEATURE_JITis effectively unavailable for the slot being dispatched. [clr-ios] Composite-r2r with interpreter fallback leads to significant IL_STUB interpretation if FEATURE_JIT is disabled #123120 already tracks the broader composite-R2R + interpreter-fallback story for IL stubs; the calli target here is plausibly one of those stubs. - Generic instantiation / shared-canon stub mis-resolution of
MethodBaseInvoker.InvokeWithOneArg's target. Prior issue .NET 10 - System.ExecutionEngineException in System.Reflection.MethodBaseInvoker.InvokeWithOneArg #123318 was exactly onMethodBaseInvoker.InvokeWithOneArgending up in a bad slot with deep generic types — different symptom (ExecutionEngineException) but suggestive that this fast path is fragile around generic dispatch. Reflection on a generic converter (which is whatXunit.Sdk.Reflector.ConvertArgumentdoes for[Theory]data) hits the same shape.
Suggested next steps
- Reproduce on iOS-arm64 simulator (catchable, attachable) and confirm
pc = 0+ identical managed frames. - Inspect the
MethodBaseInvoker.InvokeWithOneArg→callitarget setup in System.Private.CoreLib (InvokerEmitUtilor similar) and the correspondingCallStubGeneratorplumbing for theRetI8shape. - Confirm whether forcing the slow
_invokeFunc_RefArgspath (or any equivalent fallback) avoids the crash. If yes, that pinpoints the bug to the new managed invoker fast path and gives a workable[ActiveIssue]onSystem.Runtime.Testsfor iOS in the meantime.
Related
- Possibly related: [iOS][CoreCLR] System.Runtime.Tests Smoke crashes on launch with CODESIGNING / Invalid Page on iOS 26.1 device #127863 — same
.ips/ same workitem / same machine. Currently closed with a different root-cause hypothesis ("iOS 26 jit-restrict regime / W^X /MAP_JIT"). Based on the evidence in this issue:- The faulting PC is exactly
0x0, not a value inside a JIT'd code page that the kernel rejected for missing entitlements.KERN_PROTECTION_FAILURE at 0x0simply says page 0 is unmapped/unsigned and that an instruction-fetch hit it. CallJittedMethodRetI8is the I8-return variant of the interpreter's call-stub generator (introduced in Interpreter to JIT/AOT calls #115375). Its job is to read a target function pointer fromCalliStubParamand tail-call to it. If that pointer is null, the load reads 0, the branch reads 0, and the next instruction-fetch faults — independently of any iOS JIT-protection regime.- iOS 26.1 didn't change anything about how an instruction-fetch from unsigned page 0 is handled — the
CS_KILL/cs_invalid_pagepath has been there for years. Adopting Apple's new JIT APIs (Investigate use of new Apple JIT APIs #108423) is good in general but won't fix this specific crash.
- The faulting PC is exactly
MethodBaseInvoker.InvokeWithOneArgfast-path failure with similar shape on a different platform/scenario: .NET 10 - System.ExecutionEngineException in System.Reflection.MethodBaseInvoker.InvokeWithOneArg #123318 (deep generics on Windows, closed by @davidwrighton).- Composite-R2R + interpreter-fallback IL_STUB story that this likely intersects with: [clr-ios] Composite-r2r with interpreter fallback leads to significant IL_STUB interpretation if FEATURE_JIT is disabled #123120 (open).
- Other interp-stub fixes in the same area for context: Interpreter to JIT/AOT calls #115375 (introduced
CallJittedMethodRetI8/CalliStubParam), Fix args passed by stack ref in the CallStubGenerator #117399, [interp] Make InterpreterStub handle being called on threads without a Thread object #119906, [clr-interp] Fix logic around interpreter stub startup where the CallStubHeader may not be generated due to a race #120952. - Other iOS R2R + interpreter crashes worth diffing against: [clr-ios] CheckGCRefMapEqual assert failure on Apple mobile when running interpreter without R2R #125724, [clr-ios]
Microsoft.Bcl.TimeProvider.Testsfails on Apple mobile when running interpreter without R2R #125725, Crash inToString_Asynctest on Apple mobile with CoreCLR R2R and interpreter #124044. - iOS device launch surface: [Test][iOS] iOS.Device.Aot.Test fails with APP_LAUNCH_FAILURE #119665 (
APP_LAUNCH_FAILURE, different signal but same launch-time surface).
Configuration
dotnet/runtimemain(build1409391); also reported on build1409468againstmaincommit0f84a105b01per [iOS][CoreCLR] System.Runtime.Tests Smoke crashes on launch with CODESIGNING / Invalid Page on iOS 26.1 device #127863 and on unrelated PR build1410238. Not introduced by any specific PR — present onmain.- iOS 26.1, build 23B85, device class iPhone (helix
osx.15.amd64.iphone.openqueue). arm64,Releaseconfiguration, composite R2R, no AOT, no Mono, no JIT (UseMonoRuntime=false,UseNativeAOTRuntime=false,RunAOTCompilation=empty,MonoForceInterpreter=empty).
Activity
jkotas commentedon May 6, 2026
@radekdoulik Looks like a regression (race condition) introduced by caching of calli cookies
kotlarmilos commentedon May 6, 2026
Yes, I proposed a fix in #127876
Fix iOS arm64 CoreCLR crash from shared MethodDesc::CalliCookie slot (#…
Fix iOS arm64 CoreCLR crash from shared MethodDesc::CalliCookie slot (#…