Inproc crashreport ios#2
Draft
mdh1418 wants to merge 115 commits intoinproc_crashreport_minimalfrom
Draft
Conversation
mdh1418
pushed a commit
that referenced
this pull request
Apr 28, 2026
…otnet#124642) ## Summary Fixes dotnet#123621 When a constant-folded operand appears **after** a non-constant operand in a short-circuit `&&` expression (e.g., `v == 2 && Environment.NewLine != "\r\n"`), callee inlining can leave dead local stores in the return block. The `isReturnBool` lambda in `fgFoldCondToReturnBlock` required `hasSingleStmt()`, which caused the optimization to bail out when these dead stores were present, resulting in suboptimal branching codegen. ### Changes - **`src/coreclr/jit/optimizebools.cpp`**: Relax the `hasSingleStmt()` constraint in `isReturnBool` to allow preceding statements as long as they have no globally visible side effects (`GTF_GLOBALLY_VISIBLE_SIDE_EFFECTS`). This enables `fgFoldCondToReturnBlock` to fold the conditional into a branchless return even when dead local stores from inlining remain in the block. ### Before (ARM64, `Inline_After`) ```asm cmp w0, #2 bne G_M4495_IG04 mov w0, #1 ret G_M4495_IG04: mov w0, #0 ret ``` ### After (ARM64, `Inline_After`) ```asm cmp w0, #2 cset x0, eq ret ``` ## Test plan - [x] Added regression test `Runtime_123621` covering the original issue pattern - [x] Verified `Hoisted`, `Inline_Before`, and `Inline_After` all produce identical branchless codegen (`cset` on ARM64) - [x] Verified existing `DevDiv_168744` regression test still passes - [x] Verified side-effect-ful blocks are correctly excluded from the optimization
Assuming we don't care about datatargets that don't implement `GetThreadContext`. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…tNode (dotnet#127524) Fixes a use-before-def in the non-AVX-512 saturation path of `Compiler::gtNewSimdCvtNode` that produces wrong results for `Vector{128,256,512}.ConvertToInt32(Vector*<float>)` when the input is not invariant or a local. ## Repro (DOTNET_EnableAVX512=0) ```cs [MethodImpl(MethodImplOptions.NoInlining)] static Vector512<int> Test() => Vector512.ConvertToInt32(Vector512.Create(float.MinValue)); ``` Before this PR: ``` <0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2147483647, 0, 0, 0> ``` After this PR: ``` <-2147483648, -2147483648, -2147483648, -2147483648, -2147483648, -2147483648, -2147483648, -2147483648, -2147483648, -2147483648, -2147483648, -2147483648, -2147483648, -2147483648, -2147483648, -2147483648> ``` ## Root cause ```cpp GenTree* op1Clone1 = fgMakeMultiUse(&op1); // op1 := COMMA(STORE temp = orig, LCL_VAR temp); op1Clone1 := fresh LCL_VAR temp GenTree* mask1 = gtNewSimdIsNaNNode(type, op1, ...); // uses op1 (the COMMA) fixupVal = gtNewSimdBinOpNode(GT_AND_NOT, op1Clone1, mask1, …); // AND_NOT(LCL_VAR temp, IsNaN(COMMA(STORE temp, ...))) ``` `AND_NOT(a, b)` decomposes into `AND(a, NOT(b))`, so the left operand `a` evaluates first. The `LCL_VAR temp` read happens **before** the `STORE temp` that lives inside the COMMA on the right, so the AND consumes whatever was on the stack. Disasm on main with AVX-512 disabled (only the relevant block, V05 / V08 are the temps in question): ```asm vpcmpeqd ymm0, ymm0, ymm0 vandps ymm0, ymm0, ymmword ptr [rsp+0x20] ; reads V05 - never written vbroadcastss ymm1, dword ptr [reloc @rwd00] vcmpgeps ymm2, ymm0, ymm1 vbroadcastss ymm3, dword ptr [reloc @RWD04] vcvttps2dq ymm0, ymm0 vpblendvb ymm0, ymm0, ymm3, ymm2 vmovups ymm2, ymmword ptr [rsp] ; reads V08 - never written ... ``` The bug has existed since `gtNewSimdCvtNode` was first introduced; it stayed latent because pre-dotnet#127124 / dotnet#127402 the inner `IsNaN(op1)` expanded into per-element compares that kept enough materialization around to mask the bad ordering. With SIMD32/64 constant propagation, `CompareNotEqual(temp, temp)` value-numbers as AllBitsSet and the whole right subtree collapses to constants, leaving only the broken left-side read - which is exactly what `Vector512Tests.ConvertToInt32Test` started catching on non-AVX-512 hosts. ## Fix Two-line swap: pass `op1` (the COMMA, evaluated first) as `AND_NOT`'s left arg; use the clone for the IsNaN check. ```cpp GenTree* op1Clone1 = fgMakeMultiUse(&op1); GenTree* mask1 = gtNewSimdIsNaNNode(type, op1Clone1, simdSourceBaseType, simdSize); fixupVal = gtNewSimdBinOpNode(GT_AND_NOT, type, op1, mask1, simdSourceBaseType, simdSize); ``` Now the COMMA evaluates first, the STORE happens, both subsequent reads of the temp get the correct value. ## Validation - Repro produces correct output on AVX-512 disabled and AVX-512 enabled. - `Vector512Tests.ConvertToInt32Test` / `ConvertToInt32NativeTest` pass with `DOTNET_EnableAVX512=0`. - SuperPMI replay against `benchmarks.run` clean (38409 contexts, 0 failures, 0 asserts). ## Note on dotnet#127499 That PR adds an AVX-512 gate in `impSpecialIntrinsic`'s `NI_Vector512_ConvertToInt32` case. As @tannergooding pointed out in dotnet#127499 (comment) / dotnet#127499 (comment), that case is already unreachable on non-AVX-512 hosts because `Compiler::lookupId` returns `NI_Illegal` for `Vector512` ISA when AVX-512 is not opportunistically supported. I verified that applying dotnet#127499 alone leaves the test failing - the gate it adds is dead code. This PR addresses the actual bug; dotnet#127499 can be closed. Fixes dotnet#127440. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Closes dotnet#125388 Fixes dotnet#124216 Breaking change documentation: [dotnet/docs#53407](dotnet/docs#53407) ## Summary Adds a new public virtual `Type.GetNullableUnderlyingType()` method so that `Type` subclasses (e.g. `MetadataLoadContext`'s `RoType`) can correctly identify `Nullable` types. `Nullable.GetUnderlyingType()` now forwards to this virtual. This follows the same pattern as `Enum.GetUnderlyingType()` forwarding to `Type.GetEnumUnderlyingType()`. ## Contract - `Type.GetNullableUnderlyingType()` returns a non-`null` result for both: - a constructed `Nullable<T>` (returns `T`), **and** - the generic type definition `typeof(Nullable<>)` (returns the generic type parameter `T`). - `Nullable.GetUnderlyingType(Type)` continues to return `null` for the generic type definition for COMPAT. - The base `Type.GetNullableUnderlyingType()` throws `NotSupportedException`. Custom `Type` subclasses outside the BCL must override it; this is a behavioral breaking change documented in dotnet/docs#53407. ## Changes ### Public API - **`Type.cs`**: New `public virtual Type? GetNullableUnderlyingType()` that throws `NotSupportedException(SR.NotSupported_SubclassOverride)` (matches `IsByRefLike` pattern per @MichalStrehovsky's feedback). XML doc documents that the open generic `Nullable<>` is treated as nullable and yields the generic type parameter. - **`System.Runtime.cs`** / **`System.Reflection.Emit.cs`** (ref assemblies): New API + `TypeDelegator`/`TypeBuilder`/`EnumBuilder`/`GenericTypeParameterBuilder` overrides. ### `Nullable.GetUnderlyingType` rewire - **`Nullable.cs`**: Now delegates to the new virtual after preserving the `IsGenericTypeDefinition` COMPAT short-circuit. ### Runtime overrides (all three runtimes) - **`RuntimeType.CoreCLR.cs`** / **`RuntimeType.Mono.cs`**: Override that handles both constructed and open-generic cases. Open `Nullable<>` returns `GetGenericArguments()[0]` since the native fast-path can't yield a `MethodTable` for the formal type parameter `T`. - **`RuntimeType.NativeAot.cs`**: Same handling for constructed `Nullable<X>` via the EEType fast-path. - **`RuntimeTypeInfo.cs`** (NativeAOT): Added `public virtual` returning `null` (per @jkotas's feedback). - **`NativeFormatRuntimeNamedTypeInfo.cs`** (NativeAOT): Sealed override that returns the generic parameter only when the type is `typeof(Nullable<>)`. - **`RuntimeConstructedGenericTypeInfo.cs`** (NativeAOT): override for constructed generics. ### Reflection subclasses - **`TypeDelegator.cs`**: Override forwarding to `typeImpl.GetNullableUnderlyingType()`. - **`SignatureType.cs` / `SignatureConstructedGenericType.cs` / `SignatureModifiedType.cs`**: Overrides that delegate through the generic definition. - **`ModifiedType.cs`**: Override delegating through the unmodified type. ### Reflection.Emit - **`TypeBuilder.cs` / `EnumBuilder.cs` / `GenericTypeParameterBuilder.cs` / `TypeBuilderInstantiation.cs`**: Overrides returning `null` (or appropriate result for instantiations). - **`SymbolType.cs`**: Override returning `null` so `Nullable.GetUnderlyingType` doesn't throw on `MakeArrayType`/`MakePointerType`/`MakeByRefType` results from `TypeBuilder`. ### MetadataLoadContext - **`RoType.cs`**: Override using `CoreType.NullableT` identity comparison; uses `GetGenericArguments()[0]` so the open `Nullable<>` returns the MLC-projected generic parameter rather than indexing empty `GenericTypeArguments`. - **`RoModifiedType.cs`**: Override delegating through the unmodified type (required because `RoModifiedType.GetGenericTypeDefinition()` throws). ### Tests - **`NullableTests.cs`**: Coverage for `RuntimeType` (constructed + open-generic) and `TypeDelegator`. - **`SignatureTypes.cs`**: Coverage for `SignatureConstructedGenericType` and `SignatureModifiedType`. - **`ModifiedTypeTests.cs`**: New `NullableModifiedTypeHolder` (uses `volatile delegate*<int?>` to obtain a `ModifiedType` wrapping `Nullable<int>`) and tests for modified Nullable / non-Nullable. - **`TypeBuilderGetNullableUnderlyingType.cs`** (new): Coverage for `TypeBuilder`, `EnumBuilder`, `GenericTypeParameterBuilder`, `TypeBuilderInstantiation`, and `SymbolType` (Array / multi-dim Array / Pointer / ByRef). - **`TypeTests.Nullable.cs`** (MetadataLoadContext): Coverage for `RoType` (constructed + open-generic). --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Jan Kotas <jkotas@microsoft.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…trypoint platforms (dotnet#127370)
…t#126576) ## Description This adds initial func-eval support for threads stopped in CoreCLR interpreter code. - Queue interpreter func-eval requests in the existing pending evals hash table (ProcessAnyPendingEvals) instead of using native-context hijacking - Execute pending evals from InterpBreakpoint after the debugger callback returns, reusing the shared dispatch path for both interpreter and exception-time evals - Skip native-only setup for interpreter evals: executable breakpoint segment allocation, SP alignment validation, and register/context updates that rely on real native frames - Rename m_evalDuringException to m_evalUsesHijack (inverted logic) to accurately describe the flag's purpose now that it covers both exception and interpreter paths - Move Init() skip logic inside DebuggerEval so callers don't need interpreter-specific conditionals - Return CORDBG_E_FUNC_EVAL_BAD_START_POINT for func-eval requests on interpreter threads not stopped at a breakpoint - Reuse the direct completion path for interpreter evals, where completion is signaled without the native breakpoint trap mechanism ## Testing - Locally on iOS simulator - DiagnosticTests: Func-eval tests passing under --clrinterpreter (osx-arm64, validated locally) - FuncEval.NestedFuncEvalTest - FuncEval.EscapeSecondPass FuncEval.InfiniteLoopASyncAbortTest is Windows-only and FuncEval.AssemblyLoadFuncEval is a Mono configuration. Fixes dotnet#125959 --------- Co-authored-by: Milos Kotlar <kotlarmilos@gmail.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…e CoreCLR (dotnet#127058) ## Description Part of splitting dotnet#125439 into smaller, self-contained PRs. On Apple mobile platforms, test assemblies are deployed as files inside the `.app` bundle rather than being embedded as managed resources in the host test assembly. As a result, `Assembly.GetManifestResourceStream` returns null in `ResourceAssemblyLoadContext` and any test that relies on it fails. This PR updates `ResourceAssemblyLoadContext` to fall back to loading the assembly from `AppContext.BaseDirectory` when the embedded resource is not present. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Copilot <copilot@github.com>
…t#126953) ## Description When DAC/DBI seeds StackFrameIterator from a CONTEXT pointing into interpreted code, m_crawl.pFrame is initialized to the thread's top explicit Frame, which is the InterpreterFrame that owns the executing InterpMethodContextFrame chain. ResetRegDisp reads the owning InterpreterFrame* from the CONTEXT's first-arg register and advances m_crawl.pFrame past it before ProcessCurrentFrame runs. ## Tests Fixes the following interpreter debugger test failures: - `StackWalking.NestedException` - `StackWalking.ChildParentTest` --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Jan Vorlicek <janvorli@microsoft.com>
Without this condition, fresh test runs fail because there are no 'done' files indicating r2r compilation already completed
…tnet#126649) > [!NOTE] > This PR description was generated with Copilot. Reinstates the LINQ convenience overloads from dotnet#121998 and dotnet#121999 that were reverted in dotnet#126624, while also fixing the build break that caused the revert. ## Summary - preserves the original API/implementation commits by cherry-picking them onto this branch - fixes the `System.Linq.AsyncEnumerable` test build break by making the affected async selectorless overload calls explicit where inference was insufficient during the multi-target build ## Validation - `build.cmd clr+libs -rc release` - `.\dotnet.cmd build .\src\libraries\System.Linq.AsyncEnumerable\tests\System.Linq.AsyncEnumerable.Tests.csproj /t:Test --no-restore` - `.\dotnet.cmd build .\src\libraries\System.Linq\tests\System.Linq.Tests.csproj /t:Test --no-restore` - `.\dotnet.cmd build .\src\libraries\System.Linq.Queryable\tests\System.Linq.Queryable.Tests.csproj /t:Test --no-restore` --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: Shay Rojansky <roji@roji.org> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: roji <1862641+roji@users.noreply.github.com>
…arm (dotnet#127225)" (dotnet#127547) Reverts dotnet#127225 Closes dotnet#127500 android-arm is crashing in CI with `SIGSEGV` in `System.DateTime.get_Now()`. See dotnet#127500. Reverting while the underlying crash is investigated. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ol knob design (dotnet#127033) Fix IMUL register encoding, remove embedded REX prefix in opcode when necessary Disable the NDD form of CMOV due to discrepant semantic of original CMOV and NDD form, follow-up PR to reintroduce the remaining NCI instructions (CTEST and CFCMOV) has been planned. Separate PP2 and PPX control knob Hide ConditionalChaining (`DOTNET_EnableApxConditionalChaining`) behind APX (`DOTNET_EnableAPX`) knob Disable IDIV/DIV due to lack of exception handling for REX2/EVEX prefixed instructions in VM Disable TEST ACC form for REX2, it is not compatible as the form does not use EGPRs. resolve merge errors --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Kendall Gonzalez Leon <kendall.gonzalez.leon@intel.com>
## Description This PR enables StackTrace library tests on Apple mobile. The line numbers are not displayed on Apple mobile, tracked in dotnet#124087. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When multiple awaits have common context handling logic during suspension we can share that logic completely by jumping to a common block. This PR implements that size optimization.
This adds floating->long/ulong cast codegen for AVX-512 and AVX10.2 on x86. With this, all non-overflow casts are now hardware accelerated. This is the last bit pulled from dotnet#116805. Typical Diff (double->long AVX-512): ```diff - sub esp, 8 - vzeroupper - vmovsd xmm0, qword ptr [esp+0x0C] - sub esp, 8 - ; npt arg push 0 - ; npt arg push 1 - vmovsd qword ptr [esp], xmm0 - call CORINFO_HELP_DBL2LNG - ; gcr arg pop 2 + vmovsd xmm0, qword ptr [esp+0x04] + vcmpordsd k1, xmm0, xmm0 + vcmpge_oqsd k2, xmm0, qword ptr [@rwd00] + vcvttpd2qq xmm0 {k1}{z}, xmm0 + vpblendmq xmm0 {k2}, xmm0, qword ptr [@RWD08] {1to2} + vmovd eax, xmm0 + vpextrd edx, xmm0, 1 - add esp, 8 ret 8 +RWD00 dq 43E0000000000000h +RWD08 dq 7FFFFFFFFFFFFFFFh -; Total bytes of code 31 +; Total bytes of code 53 ``` Full [Diffs](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1391699&view=ms.vss-build-web.run-extensions-tab) Breakdown of the double->long asm: ```asm ; load the scalar double vmovsd xmm0, qword ptr [esp+0x04] ; set the low bit of k1 if the scalar value is not NaN vcmpordsd k1, xmm0, xmm0 ; set the low bit of k2 if the input was greater than or equal to 2^63 (nearest double greater than long.MaxValue) vcmpge_oqsd k2, xmm0, qword ptr [@rwd00] ; convert, using k1 mask bit. if the mask bit is not set (meaning we have a NaN), set the value to zero vcvttpd2qq xmm0 {k1}{z}, xmm0 ; if the low bit of k2 is set (meaning overflow), set the value to long.MaxValue, otherwise take the conversion result vpblendmq xmm0 {k2}, xmm0, qword ptr [@RWD08] {1to2} ; extract the two 32-bit halves of the long result vmovd eax, xmm0 vpextrd edx, xmm0, 1 ``` --------- Co-authored-by: Tanner Gooding <tagoo@microsoft.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…t#127220) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Jan Kotas <jkotas@microsoft.com>
This is the `X25519DiffieHellmanOpenSsl` implementation that works with EVP_PKEY handles.
## Description `DeadThreads` creates threads at a very high rate, making it unsuitable for GC stress runs where frequent GCs slow execution enough to cause OOM or excessive paging. ### Changes - **`src/tests/baseservices/threading/DeadThreads/DeadThreads.csproj`**: Added `<GCStressIncompatible>true</GCStressIncompatible>` to opt the test out of GC stress (GCStress3/GCStressC) runs. ## AI Generated Content Notice > [!NOTE] > This PR description was generated by GitHub Copilot. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: VSadov <8218165+VSadov@users.noreply.github.com>
…dExportedTypeByName (dotnet#127471) > [!NOTE] > This PR was AI/Copilot-generated. ## Summary Implements 4 IMetaDataImport/IMetaDataAssemblyImport methods that were previously legacy-only stubs in `MetaDataImportImpl`. These APIs are used by an internal debugger and need cDAC implementations for no-fallback mode. Also adds comprehensive DEBUG parity validation across all cDAC-implemented methods and improves code quality. ## Changes ### New cDAC implementations in `MetaDataImportImpl.cs` | Method | Interface | Description | |--------|-----------|-------------| | `EnumTypeDefs` | IMetaDataImport | Enumerates all TypeDef tokens via `MetadataReader.TypeDefinitions` | | `EnumMethods` | IMetaDataImport | Enumerates methods of a TypeDef via `TypeDefinition.GetMethods()` | | `GetExportedTypeProps` | IMetaDataAssemblyImport | Returns exported type name (namespace.name), implementation token, TypeDef ID, and flags | | `FindExportedTypeByName` | IMetaDataAssemblyImport | Finds an exported type by full name, with nested type support via enclosing type token | All implementations follow the established patterns in MetaDataImportImpl: - try/catch with HResult return - `FillEnum` infrastructure for enum methods - `CopyStringToBuffer` with truncation → `CLDB_S_TRUNCATION` - `CLDB_E_RECORD_NOTFOUND` for missing records - `#if DEBUG` validation against legacy DAC ### Comprehensive DEBUG parity validation Added or improved `#if DEBUG` validation blocks for **all** cDAC-implemented methods: - **3 enum methods** (`EnumInterfaceImpls`, `EnumFields`, `EnumGenericParams`) — added missing DEBUG blocks that enumerate via the legacy DAC and compare token lists - **9 Get methods** — added string content validation (not just length) by passing `stackalloc` name buffers to the legacy DAC and comparing the actual strings - **2 Get methods** (`GetGenericParamProps`, `GetParamProps`) — added name length + string validation that was previously missing entirely - All enum DEBUG blocks follow the SOSDacImpl pattern: placed **after** the catch block, not inside the try ### Code quality improvements - **`EcmaMetadataUtils.GetRowId`** made public; added `private static int GetRID(uint token)` helper in `MetaDataImportImpl` to replace all raw `& 0x00FFFFFF` RID mask usage - **Named CLDB HRESULT constants** (`CldbHResults.CLDB_S_TRUNCATION`, etc.) used in tests instead of magic hex literals ### Dump tests in `MetaDataImportDumpTests.cs` - `EnumTypeDefs_MatchesMetadataReader` — enumerates TypeDefs via cDAC and compares against `MetadataReader.TypeDefinitions` - `EnumMethods_MatchesMetadataReader` — enumerates methods per TypeDef and compares against `MetadataReader` ### Unit tests in `MetaDataImportImplTests.cs` - 11 new unit tests covering: basic enumeration, pagination, per-TypeDef method enumeration, global methods, empty method lists, exported type properties, nested exported types, truncation, find by name, nested find, and not-found cases - Updated `NotImplementedMethods_ReturnENotImpl` to remove `EnumTypeDefs` (now implemented) - Added exported type entries to shared test metadata builder ## Testing - **1856 unit tests** pass (all cDAC tests) - **5 dump tests** pass (MetaDataImport-specific) - Build succeeds with 0 errors, 0 warnings --------- Co-authored-by: Max Charlamb <maxcharlamb@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
## Description Replaces the legacy-delegation stub in `DacDbiImpl.EnumerateAssembliesInAppDomain` with a managed implementation using the `ILoader` contract, mirroring the native C++ logic in `dacdbiimpl.cpp:4412–4449`. ### Changes - **`IDacDbiInterface.cs`**: Changed `fpCallback` parameter type from `nint` to `delegate* unmanaged<ulong, nint, void>` (consistent with `EnumerateThreads`) - **`DacDbiImpl.cs`**: Full implementation that: - Returns `S_OK` early on null `vmAppDomain` - Enumerates via `ILoader.GetModuleHandles` with `IncludeLoading | IncludeLoaded | IncludeExecution` - Resolves each `ModuleHandle` to an assembly pointer via `ILoader.GetAssembly` - Calls `fpCallback(assembly, pUserData)` per entry - `#if DEBUG` validation against legacy DAC (same pattern as `EnumerateThreads`) - DacDbiImplTests.cs - Add 5 tests covering zero AppDomain, null callback, single/multiple/empty assembly enumeration with mocked ILoade --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: barosiak <76071368+barosiak@users.noreply.github.com> Co-authored-by: Barbara Rosiak <brosiak@microsoft.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…Silicon (dotnet#127355) ## Problem On macOS Apple Silicon (observed on macOS 15), compressed self-contained single-file apps intermittently hit `AccessViolationException` crashes. With the repro provided in the issue, the failure rate was roughly 75% in a local run. `FlatImageLayout::LoadImageByCopyingParts` allocates the image region with `MEM_RESERVE_EXECUTABLE` (which maps to `MAP_JIT` on macOS) as `PAGE_READWRITE`, copies in all section bytes, then promotes executable sections to `PAGE_EXECUTE_READWRITE` via a second `mprotect`. On Apple Silicon, this `RW → RWX` transition on MAP_JIT memory has been observed to intermittently succeed at the API level but leave pages non-executable at the kernel level, producing the sporadic AVs. ## Fix On Apple Silicon (`HOST_OSX && HOST_ARM64`), avoid the unreliable transition: reserve the whole image region as `PAGE_NOACCESS` up front, then commit each section directly with its final runtime protection (`PAGE_EXECUTE_READWRITE` for exec, `PAGE_READWRITE` otherwise), copying executable content under `PAL_JitWriteProtect`. The `PROT_NONE → RWX` direction via a fresh commit is reliable; the problematic `RW → RWX` transition no longer occurs. Read-only sections are still downgraded from `PAGE_READWRITE` to `PAGE_READONLY` after the copy, which is a W-removing transition and is not implicated in the original bug. The non-Apple-Silicon code path is unchanged. ## Testing New test: `AppHost.Bundle.Tests.AppLaunch.SelfContained_Compressed_SpawnsChildren` (OSX-only). Adds a `launch_self` option to the `HelloWorld` test asset that spawns 5 copies of itself in parallel, and asserts the parent runs to completion. Local validation on Apple Silicon: - Without fix: parent crash with `AccessViolationException` in ~74% of trials at N=5 children (rises to ~98% at N≥12). - With fix: 0 failures across 50+ trials at N=5. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…et#127369) Several `TokenBasedNode` subclasses in ILTrim were not calling `CustomAttributeNode.AddDependenciesDueToCustomAttributes`, causing custom attributes on those metadata tables to be silently dropped during trimming.
1. Agent is sometimes ignoring the result of the version calculation script - make it more clear how to handle results. 2. Comment was duplicating issue body. Remove this. 3. Tag the PR's assignees to get attention. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…tnet#127539) More code can be replaced with safe in this assembly, but that requires work in the jit side. Current change produces improvements: [diffs](MihuBot/runtime-utils#1870) --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This is a fix for an issue that came up in dotnet#126778, and is probably easiest to explain with a motivating example. Consider the following case, where NOMOVE is a gentree operation we aren't allowed to move. ``` t2 = ... NOMOVE OP t3 = ... OP t0 = ... NOMOVE OP t1 = ... OP * t3 (arg1) * t2 (arg2) * t1 (arg3) * t0 (target) CALL ``` The stackifier will first introduce a store to put `t0` after `t1`: ``` t2 = ... NOMOVE OP t3 = ... OP t0 = ... OP +** STORE_LCL_VAR tmp0 t1 = ... OP t0 = LCL_VAR tmp0 * t3 (arg1) * t2 (arg2) * t1 (arg3) * t0 (call target) CALL ``` And then recursively stackify the new STORE to tmp0, since it is a dataflow root. *The stackifier then marks tmp0 as free here, since it IS free in linear data flow order*. Then, when the next operands to the call are stackified, the stackifier introduces a temporary again, but reuses t0 because we freed it. ``` t2 = ... OP +** STORE_LCL_VAR tmp0 t3 = ... OP t2 = LCL_VAR tmp0 t0 = ... OP +** STORE_LCL_VAR tmp0 t1 = ... OP t0 = LCL_VAR tmp0 * t3 * t2 * t1 * t0 (target) CALL ``` This produces invalid LIR; there is a store to tmp0 before one of its reads (t2) is consumed. The simplest fix is to not release temporaries for reuse until all operands of a root tree have been processed. This PR adds a free list of temps which is recycled after each root gen tree has been processed, so we won't end up with any interference between temporaries while processing gentree ops which share a parent node. --------- Co-authored-by: SingleAccretion <62474226+SingleAccretion@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Initially cherry-picked commit from dotnet#126662; This PR: - Adds explicit handling in lowering for managed calls using the PEP calling convention to pass the additional PEP parameter. - Removes some dead code around handling of `WellKnownArg::R2RIndireictionCell` from wasm code gen. - Adds fixes for helper call codegen to account for the extra level of indirection needed to load a helper call target from a PEP (Portable Entrypoint). ## Lowering Transformation Details The lowering transformation introduces a temp local (call it `pep`) to hold the PEP, which we then add to a managed call as a final parameter with associated ABI info. We then rewrite the control expr of the call to be `*pep`. This ensures that, conceptually, any call with an entrypoint of access type `PVALUE` will be lowered to something roughly like the following, in C notation: ``` void* pep = *(void**)(<value>); (*(void**)pep)(arg0, arg1, ..., argN, pep) ``` --------- Co-authored-by: David Wrighton <davidwr@microsoft.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…otnet#127633) ## Summary This PR fixes a correctness issue in `SetEquals` introduced in my previous PR dotnet#126309. The `Count` check was moved inside the `Comparer` equality block. This ensures that when comparers differ, we don't return a false negative and instead fall back to the safe path. ### Example of the issue fixed: ```csharp // This should return true, but was returning false var main = ImmutableHashSet.Create(StringComparer.OrdinalIgnoreCase, "a"); var other = ImmutableHashSet.Create("a", "A"); Console.WriteLine(main.SetEquals(other)); ``` ## Changes - Moved `if (count != origin.Count)` inside the `EqualityComparer<IEqualityComparer<T>>.Default.Equals` check. - This ensures mismatched comparers safely bypass the fast-path and proceed to a proper set comparison. ## Testing In addition to the fix, I have added comprehensive unit tests covering various scenarios to ensure correctness: - **Mismatched Comparers (Ordinal vs. OrdinalIgnoreCase):** Verified that `SetEquals` returns `true` when logically equal but with different comparers, and `false` when logically different. - **ICollection with Duplicates:** Verified the fallback path correctly handles collections like `List<T>` with duplicate elements. - **Count Optimizations:** - Verified that mismatched comparers correctly bypass the fast-path count check. - Verified that `SetEquals` still performs early-exit when `other.Count < origin.Count`. - **Fast-Path Validation:** Ensured that when comparers match, the optimized count-based comparison still works as expected. - **Edge Cases:** Included tests for empty sets with different comparers and content-specific mismatches. **Related to:** dotnet#126309
We special case it as consisting of 2 I8s. Fixes `System.Resources.Extensions.BinaryFormat.Tests` crashes when a method returning `TypedReference` gets called from interpreter via JIT.
…t#127677) The idea in dotnet#126222 was to hide CallEntryPoint helper in the unhandled exception stacktraces, but it did not actually happen.
) ## Description The mobile platform failure scanner has been failing with permission-denied errors and produced a mix of PRs, issues, and repeated comments on the same issues across runs. This change makes the workflow simpler and more predictable. Now every mobile failure either becomes a draft PR (when there's a per-test fix like `[SkipOnPlatform]`) or a tracking issue (for product bugs, native crashes, multi-assembly regressions, or infra problems that need an owner). The workflow no longer files comments and no longer ends a run with `noop`. Other changes: - Cap raised to 5 PRs and 3 issues per run. - PRs now only touch test files (`src/libraries/**/tests/**` and matching `.csproj`); anything else fails PR creation. - PR and issue bodies use a fixed structure: Reasoning, Impact on platforms, Errors log, First build it occurred (issues add a Recommended action section). - Removed broken references in the prompt (`pwsh Get-CIStatus.ps1`, `gh search prs`) and dropped `pwsh` from the allowlist. Validated with one workflow_dispatch run on this branch where it produced three issues dotnet#127563, dotnet#127564, dotnet#127565. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
> [!NOTE] > This pull request description was generated by GitHub Copilot. ## Summary - Disable the `android_arm` Mono library test matrix entry in the default runtime pipeline. - Disable the same `android_arm` entry in the Android-only extra-platforms pipeline. - Leave Android arm64 coverage enabled. References dotnet#125440. ## Testing - `git diff --check -- eng\pipelines\runtime.yml eng\pipelines\extra-platforms\runtime-extra-platforms-android.yml` Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Wire up basic gc info encoding in the wasm jit * Build gcinfo_universal_wasm and link it into the wasm version of the jit * Move gcdecode/gcencode into JIT_SOURCES * Remove the TARGET_WASM exclusion for the gc info encoder and decoder * Define a Wasm32 GcInfoEncoding * Allow building with EMIT_GENERATE_GCINFO on targets without a fixed register set like Wasm, and set EMIT_GENERATE_GCINFO on Wasm * Never generate tracked gc slots on Wasm * Update wasm regalloc to never enregister gc refs * Consume temporary regs for the operand of GT_NULLCHECK nodes to handle the case where a dead block store leaves behind an orphaned indirection that turns into a null check
…sing prctl(PR_SET_PDEATHSIG) (dotnet#127112) ## Description Adds Linux and Android support for `ProcessStartInfo.KillOnParentExit` using `prctl(PR_SET_PDEATHSIG)`. Since `PR_SET_PDEATHSIG` fires when the calling *thread* exits (not the process), a dedicated long-lived thread is used to perform `fork+exec` so the signal is only delivered when the process exits. ### Key design decisions - **Dedicated thread**: `EnsurePDeathSigThread` lazily starts a detached thread that lives for the process lifetime. The thread-start check uses a plain `bool` protected by the mutex (no atomics needed since the check is always done under the mutex). - **Mutex/condvar synchronization**: Callers submit a `PDeathSigForkRequest` struct to the dedicated thread via a shared pointer, protected by a mutex. Callers wait for `s_pdeathsig_request == NULL` before submitting to prevent overwriting a pending request, and each request has a per-request `done` flag to avoid lost-wakeup issues. - **Orphan detection**: After `prctl(PR_SET_PDEATHSIG)` in the child, a `getppid()` check detects if the parent died between `fork` and `prctl`, since `PR_SET_PDEATHSIG` will not deliver the signal in that case. - **`KillOnParentExit` passed unconditionally**: The managed code passes `KillOnParentExit` to the native shim unconditionally; the native side handles unsupported platforms as a no-op via `HAVE_PR_SET_PDEATHSIG`. - **Android support**: `PR_SET_PDEATHSIG` is available on Android, so `[SupportedOSPlatform("android")]` is added alongside `[SupportedOSPlatform("linux")]`. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com> Co-authored-by: Adam Sitnik <adam.sitnik@gmail.com> Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
dotnet#127472) Renames the `area-assemblyloading` label to `area-AssemblyLoader` to align with the casing convention used by other area labels (e.g., `area-AssemblyLoader-mono`). ## Description - `.github/policies/resourceManagement.yml` — updated `labelAdded` trigger and `hasLabel` condition - `docs/area-owners.md` — updated area label column - `.github/skills/issue-triage/references/area-label-heuristics.md` — updated heuristics table entry --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
…xception dispatch (dotnet#127741) After dotnet#127300 removed ExInfo::m_hThrowable and SetThrowable(), Thread::m_LastThrownObjectHandle is no longer updated during active exception dispatch. This causes a staleclastThrownObjectHandle to ge returned by GetThreadData when a debugger breaks into the target mid-dispatch. When debugging a .NET 11 process with SOS (e.g. via dotnet-dump or WinDbg), the following commands fail if the debuggee is stopped during exception dispatch (for example, with SXE CLR): - !PrintException — reports "Invalid exception object" because it dereferences the stale handle and gets a null or recycled pointer - !Threads — shows no exception column for threads that are actively throwing - !clrstack -a with exception context — may show incomplete or missing exception info
…t#127748) Renovate was updating container image digests with individual PRs (e.g. dotnet#127739, dotnet#127738). This is the default behavior of Renovate, to create a separate PR for each dependency name. This is prevented by adding a `groupName` to the package rule. This ensures that all digest pinning is grouped together as one unit. A `groupSlug` is also defined to explicitly define the programmatic name that would be used for things like branch name.
dotnet#126888 (comment) --------- Co-authored-by: Jan Kotas <jkotas@microsoft.com> Co-authored-by: Juan Hoyos <19413848+hoyosjs@users.noreply.github.com>
Might fix native AOT outerloops:
```
[FAIL] System.Threading.Tasks.Tests.AsyncProfilerTests.RuntimeAsync_CallstackSimulation_HandledException
Expected at least one ResumeAsyncCallstack event
at System.Threading.Tasks.Tests.AsyncProfilerTests.AssertCallstackSimulationReachesZero(ConcurrentQueue`1 events) in /_/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/System.Runtime.CompilerServices/AsyncProfilerTests.cs:line 653
at System.Reflection.DynamicInvokeInfo.Invoke(Object, IntPtr, Object[], BinderBundle, Boolean) in /_/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/DynamicInvokeInfo.cs:line 230
[FAIL] System.Threading.Tasks.Tests.AsyncProfilerTests.RuntimeAsync_WrapperIndexMatchesCallstack
Assert.All() Failure: 3 out of 3 items in the collection did not pass.
[0]: Item: Tuple ("WrapperTestC", -1)
Error: WrapperTestC did not find Continuation_Wrapper_N on stack (slot=-1)
[1]: Item: Tuple ("WrapperTestB", -1)
Error: WrapperTestB did not find Continuation_Wrapper_N on stack (slot=-1)
[2]: Item: Tuple ("WrapperTestA", -1)
Error: WrapperTestA did not find Continuation_Wrapper_N on stack (slot=-1)
at System.Threading.Tasks.Tests.AsyncProfilerTests.RuntimeAsync_WrapperIndexMatchesCallstack() in /_/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/System.Runtime.CompilerServices/AsyncProfilerTests.cs:line 1281
at System.Reflection.DynamicInvokeInfo.Invoke(Object, IntPtr, Object[], BinderBundle, Boolean) in /_/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/DynamicInvokeInfo.cs:line 230
[FAIL] System.Threading.Tasks.Tests.AsyncProfilerTests.RuntimeAsync_UnhandledExceptionUnwind
Assert.Contains() Failure: Item not found in collection
Collection: []
Not found: ResumeAsyncContext
at System.Threading.Tasks.Tests.AsyncProfilerTests.RuntimeAsync_UnhandledExceptionUnwind() in /_/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/System.Runtime.CompilerServices/AsyncProfilerTests.cs:line 1217
at System.Reflection.DynamicInvokeInfo.Invoke(Object, IntPtr, Object[], BinderBundle, Boolean) in /_/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/DynamicInvokeInfo.cs:line 230
[FAIL] System.Threading.Tasks.Tests.AsyncProfilerTests.RuntimeAsync_PeriodicTimerFlush_PreservesOwnerThreadId
Expected periodic timer to flush core lifecycle events within timeout
at System.Threading.Tasks.Tests.AsyncProfilerTests.<>c__DisplayClass102_0.<RuntimeAsync_PeriodicTimerFlush_PreservesOwnerThreadId>b__1() in /_/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/System.Runtime.CompilerServices/AsyncProfilerTests.cs:line 1439
at System.Diagnostics.Tracing.TestEventListener.RunWithCallback(Action`1 handler, Action body) in /_/src/libraries/Common/tests/System/Diagnostics/Tracing/TestEventListener.cs:line 116
at System.Threading.Tasks.Tests.AsyncProfilerTests.RuntimeAsync_PeriodicTimerFlush_PreservesOwnerThreadId() in /_/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/System.Runtime.CompilerServices/AsyncProfilerTests.cs:line 1396
at System.Reflection.DynamicInvokeInfo.Invoke(Object, IntPtr, Object[], BinderBundle, Boolean) in /_/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/DynamicInvokeInfo.cs:line 230
[FAIL] System.Threading.Tasks.Tests.AsyncProfilerTests.RuntimeAsync_ResetAsyncThreadContextEvent
Assert.Contains() Failure: Item not found in collection
Collection: []
Not found: ResetAsyncThreadContext
at System.Reflection.DynamicInvokeInfo.Invoke(Object, IntPtr, Object[], BinderBundle, Boolean) in /_/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/DynamicInvokeInfo.cs:line 230
Unhandled exception. Xunit.Sdk.TrueException: Expected first flush of core lifecycle events within timeout
at Xunit.Assert.True(Nullable`1, String) in /_/src/arcade/src/Microsoft.DotNet.XUnitAssert/src/BooleanAsserts.cs:line 135
at System.Threading.Tasks.Tests.AsyncProfilerTests.<>c__DisplayClass102_0.<RuntimeAsync_PeriodicTimerFlush_PreservesOwnerThreadId>b__2() in /_/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/System.Runtime.CompilerServices/AsyncProfilerTests.cs:line 1425
at System.Threading.Thread.StartThread(IntPtr) in /_/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Thread.NativeAot.cs:line 443
at System.Threading.Thread.ThreadEntryPoint(IntPtr) in /_/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Thread.NativeAot.Unix.cs:line 92
DOTNET_DbgEnableMiniDump is set and the createdump binary does not exist: ./createdump
[FAIL] System.Threading.Tasks.Tests.AsyncProfilerTests.RuntimeAsync_CallstackNativeIPDeltaRoundtrip
Assert.NotEmpty() Failure: Collection was empty
at System.Threading.Tasks.Tests.AsyncProfilerTests.RuntimeAsync_CallstackNativeIPDeltaRoundtrip() in /_/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/System.Runtime.CompilerServices/AsyncProfilerTests.cs:line 1715
at System.Reflection.DynamicInvokeInfo.Invoke(Object, IntPtr, Object[], BinderBundle, Boolean) in /_/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/DynamicInvokeInfo.cs:line 230
[FAIL] System.Threading.Tasks.Tests.AsyncProfilerTests.RuntimeAsync_CreateAndFirstResumeCallstacksMatch
Assert.NotEmpty() Failure: Collection was empty
at System.Threading.Tasks.Tests.AsyncProfilerTests.RuntimeAsync_CreateAndFirstResumeCallstacksMatch() in /_/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/System.Runtime.CompilerServices/AsyncProfilerTests.cs:line 1071
at System.Reflection.DynamicInvokeInfo.Invoke(Object, IntPtr, Object[], BinderBundle, Boolean) in /_/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/DynamicInvokeInfo.cs:line 230
[FAIL] System.Threading.Tasks.Tests.AsyncProfilerTests.RuntimeAsync_CallstackSimulation_UnhandledException
Expected at least one ResumeAsyncCallstack event
at System.Threading.Tasks.Tests.AsyncProfilerTests.AssertCallstackSimulationReachesZero(ConcurrentQueue`1 events) in /_/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/System.Runtime.CompilerServices/AsyncProfilerTests.cs:line 653
at System.Reflection.DynamicInvokeInfo.Invoke(Object, IntPtr, Object[], BinderBundle, Boolean) in /_/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/DynamicInvokeInfo.cs:line 230
[FAIL] System.Threading.Tasks.Tests.AsyncProfilerTests.RuntimeAsync_ContextEventIdLifecycle
Expected at least one CreateAsyncContext with id
at System.Threading.Tasks.Tests.AsyncProfilerTests.RuntimeAsync_ContextEventIdLifecycle() in /_/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/System.Runtime.CompilerServices/AsyncProfilerTests.cs:line 781
at System.Reflection.DynamicInvokeInfo.Invoke(Object, IntPtr, Object[], BinderBundle, Boolean) in /_/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/DynamicInvokeInfo.cs:line 230
./RunTests.sh: line 173: 18 Aborted (core dumped) ./System.Threading.Tasks.Tests -notrait category=IgnoreForCI -notrait category=OuterLoop -notrait category=failing -xml testResults.xml $RSP_FILE
/root/helix/work/workitem/e
----- end Mon May 4 11:48:57 AM UTC 2026 ----- exit code 134 ----------------------------------------------------------
exit code 134 means SIGABRT Abort. Managed or native assert, or runtime check such as heap corruption, caused call to abort(). Core dumped.
```
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: lateralusX <11529140+lateralusX@users.noreply.github.com>
The ultimate goal here is to remove the single-IG prolog constraint. Currently, the `igNum` order matches the linked list order precisely (and thus the final layout order) precisely. It means we cannot generate any IGs "out of order". This change removes this restriction for a subset of IGs, those representing epilogs and funclet prologs, by hiding `igNum` behind and abstraction of "before [in layout order] / after [in layout order]" APIs. These APIs rely in the linked list to ascertain ordering between out-of-order groups. Currently this is only exercised under a stress mode which splits all IGs into single-instruction groups. To this end, validation has been performed **with this stress mode uncoditionally turned on for all methods** [and all eligible IGs]. Without stress, this is a zero-diff change since all our epilogs and funclet prologs fit into a single IG currently. --------- Co-authored-by: Andy Ayers <andya@microsoft.com>
…in FilterSpec parsing (dotnet#127686) Fixes dotnet#127681
Avoid mutating the live MethodInfo from GetCodeOffset debug validation so hardware-fault stack walks keep the executionAborted flag for GC root reporting.
…tnet#127523) Async resumption stub fixups were added directly to the compiled method node, bypassing the existing precode fixup path that deduplicates fixups and only commits them after a successful compile. The fixups were eventually still deduplicated, but this is the preferred method for adding a fixup. Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jtschuster <36744439+jtschuster@users.noreply.github.com>
…cript-based tests. (dotnet#127566) The LongProcessNamesAreSupported and ProcessNameMatchesScriptName tests spawn a shell script that runs sleep as a grandchild. Killing only the shell left the sleep process alive, holding stdout/stderr pipes open for the parent that runs the tests. --------- Co-authored-by: Adam Sitnik <adam.sitnik@gmail.com>
…27742) ## Summary Fixes failing `System.Net.NameResolution` tests on Android by adding `ActiveIssue` attributes to skip tests that expect localhost subdomain resolution to return loopback addresses. ## Details On Android, DNS resolution for `.localhost` subdomains (e.g., `foo.localhost`, `test.localhost`) returns link-local IPv6 addresses (`fe80::/10`) instead of loopback addresses, causing test failures. ### Tests Fixed - `DnsGetHostEntry_LocalhostSubdomain_ReturnsLoopback` - `DnsGetHostAddresses_LocalhostSubdomain_ReturnsLoopback` These tests are now skipped on Android with reference to existing issue dotnet#124751, which already tracks the same underlying problem for the `RespectsAddressFamily` variants of these tests. ### Build Information - **Build**: [1406427](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1406427) - **Date**: 2026-05-03 - **Job**: android-arm Release AllSubsets_Mono - **Helix Job**: 6255e58e-bf4f-4c25-ba48-27c957d4ea3e - **Work Item**: System.Net.NameResolution.Functional.Tests ### Console Log Excerpt (sanitized) ``` [20:56:01] info: Instrumentation finished normally with exit code 1 [FAIL] System.Net.NameResolution.Tests.GetHostAddressesTest.DnsGetHostAddresses_LocalhostSubdomain_ReturnsLoopback(hostName: "foo.localhost") Assert.All() Failure: 2 out of 3 items in the collection did not pass. Error: Expected loopback address but got: fe80::cb7c:d6fd:eb1f:6f44%10 Error: Expected loopback address but got: fe80::b4f2:efff:fea1:dbef%3 [FAIL] System.Net.NameResolution.Tests.GetHostAddressesTest.DnsGetHostAddresses_LocalhostSubdomain_ReturnsLoopback(hostName: "test.localhost") Assert.All() Failure: 2 out of 3 items in the collection did not pass. Error: Expected loopback address but got: fe80::cb7c:d6fd:eb1f:6f44%10 Error: Expected loopback address but got: fe80::b4f2:efff:fea1:dbef%3 ``` The tests receive link-local IPv6 addresses instead of the expected loopback addresses (127.0.0.1 or ::1). ### Root Cause Android's DNS resolver behavior for RFC 6761 localhost subdomains differs from desktop platforms. When the OS resolver fallback tries to resolve plain "localhost" with or without an address family filter, Android may return the device's network interface addresses instead of loopback addresses. ### Related Issue Closes: dotnet#124751 > [!NOTE] > This content was generated by GitHub Copilot and may contain AI-generated content. > [!NOTE] > <details> > <summary>🔒 Integrity filter blocked 2 items</summary> > > The following items were blocked because they don't meet the GitHub integrity level. > > - [dotnet#19443](dotnet#19443) `search_issues`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved". > - [dotnet#126805](dotnet#126805) `search_pull_requests`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved". > > To allow these resources, lower `min-integrity` in your GitHub frontmatter: > > ```yaml > tools: > github: > min-integrity: approved # merged | approved | unapproved | none > ``` > > </details> > Generated by [Mobile Platform Failure Scanner](https://github.com/dotnet/runtime/actions/runs/25316071096/agentic_workflow) · ● 3.6M · [◷](https://github.com/search?q=repo%3Adotnet%2Fruntime+%22gh-aw-workflow-id%3A+mobile-scan%22&type=pullrequests) <!-- gh-aw-agentic-workflow: Mobile Platform Failure Scanner, engine: copilot, model: claude-sonnet-4.5, id: 25316071096, workflow_id: mobile-scan, run: https://github.com/dotnet/runtime/actions/runs/25316071096 --> <!-- gh-aw-workflow-id: mobile-scan --> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Milos Kotlar <kotlarmilos@gmail.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2cb34d2 to
81500a1
Compare
Avoid repeated expensive calls to get calli cookie by caching it Checked in HelloWorld ``` CalliCookie cache: 18 hits, 17 misses, 35 total (51.4% hit rate) ``` --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Jan Kotas <jkotas@microsoft.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Android CoreCLR does not currently have the same out-of-proc `createdump` experience available on other platforms. That makes native crashes, aborts, and mixed managed/native failures significantly harder to diagnose in real applications. This PR adds an **opt-in in-proc crash reporter for Android CoreCLR** that emits a **JSON-formatted crash report** modeled after `createdump`'s `CrashReportWriter`. The report is structurally compatible with createdump's output (same envelope, same per-thread / per-frame fields, every value emitted as a quoted JSON string including booleans and numerics) so the same downstream tooling can consume both reports. There are **two intentional schema deviations** from createdump for Android in-proc reports: - **`signal` instead of `ExceptionType`.** createdump emits a Windows-shaped `ExceptionType` field, which is meaningless on Unix where the crash is identified by the POSIX signal number. The in-proc reporter emits the signal number directly (per earlier reviewer feedback). Tooling that branches on createdump's `ExceptionType` should add a `signal`-aware path for Android reports. - **No root `pid` field.** createdump exposes the dumped process's PID because it runs out-of-process; the in-proc reporter runs inside the crashing process, so the PID is implicit and is already encoded in the report filename via the `%p` template substitution. When enabled, the runtime writes a `*.crashreport.json` file directly from the crash path to the location derived from `DOTNET_DbgMiniDumpName`. The long-term intent is for this reporting path to be **async-signal-safe**. This PR starts that work by making the lower-risk / low-hanging pieces fit that model where practical, while leaving the more complex runtime-state publication and hardening work to follow-up PRs. ## Enabling the crash reporter The crash reporter is **opt-in**, and requires both env vars to be set. ### Enable JSON crash reporting ```bash DOTNET_EnableCrashReport=1 DOTNET_DbgMiniDumpName=/data/data/<package>/files/dotnet_crash_%p ``` When configured this way, the runtime will write the report to: ```text /data/data/<package>/files/dotnet_crash_<pid>.crashreport.json ``` `DOTNET_DbgMiniDumpName` is required and is expected to be a writable absolute path. Template substitution is supported via `%p` (PID), `%d` (PID alias), `%e` (process / executable name), `%h` (host name, captured at startup), and `%t` (UNIX timestamp), matching createdump's `FormatDumpName`. If `DOTNET_DbgMiniDumpName` is unset or the file cannot be opened, no report is written. The reporter does **not** synthesize a fallback path: open-coded `TMPDIR` / `Path.GetTempPath` resolution from a fatal-signal context is security-sensitive and intentionally left to the host (this matches createdump's existing contract for the same setting). ## Current design note This PR is intentionally the **first step**, not the complete hardening story. The payload shape and reporting path are designed with **async-signal-safety** as the target, but today the implementation is a mix of: - crash-time logic that is already close to signal-safe - best-effort runtime inspection for richer managed diagnostics Follow-up PRs will continue hardening the remaining pieces so the implementation better matches the intended strict crash-path constraints. ## Example crash report shapes https://gist.github.com/mdh1418/31b36ef77d3c057ff061b92e28b527d7 ## Follow-up work - **Cross-platform support** The reporter library and the PAL callback ABI are already platform-neutral; what remains is per-platform `ucontext_t` register extraction, validation on each target, and host-side opt-in wiring. - **Emit the report to logcat / stderr in addition to the file.** Useful when no writable file location is available or when capturing logs from CI / device farms. - **Crash-report file lifecycle on Android.** The app's private files/ directory has no OS-level rotation (unlike desktop where tmpwatch / systemd / a CI step typically prunes), so a crash-looping app can accumulate *.crashreport.json files indefinitely when DbgMiniDumpName uses a %p template. Need a host-side rotation policy (cap on file count, age-based cleanup at startup, or single-slot overwrite) appropriate for sandboxed apps. - **Cross-runtime temp-directory helper.** Mono / EventPipe also have ad-hoc `g_get_tmp_dir` / `ep_rt_temp_path_get` helpers. A shared async-signal-safe helper (matching the security model of the managed `Path.GetTempPath`) would let the reporter optionally fall back to a tempdir. - **Misleading-throwable suppression.** The reporter currently skips `getExceptionCallback` only for `SIGSEGV`/`SIGBUS`. A native fault while a managed throwable is pinned on the thread (e.g., during an in-flight `EX_THROW`) can still surface as `SIGABRT`/`SIGILL`/`SIGFPE` and report a stale exception. A complete fix needs a TLS "currently dispatching" flag in the VM. - **Stress log integration.** Dump the in-process stress log into the JSON report (and/or logcat) when enabled. - **Async-signal-safety hardening of the remaining best-effort paths.** Replace the remaining VM helpers in the crash path with strictly signal-safe equivalents (frame metadata lookup, IL offset resolution, etc.). --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Broaden the Android-only opt-in for the in-proc crash reporter to cover the other mobile Apple platforms: iOS, tvOS, and MacCatalyst. None of these ship with createdump, so the in-proc reporter is the only crash-report path available and the Android integration pattern applies directly. FEATURE_INPROC_CRASHREPORT in clrfeatures.cmake is extended from CLR_CMAKE_TARGET_ANDROID to also cover CLR_CMAKE_TARGET_IOS, CLR_CMAKE_TARGET_TVOS, and CLR_CMAKE_TARGET_MACCATALYST; no other build plumbing is needed because the existing PAL callback registration and DOTNET_EnableCrashReport / DOTNET_EnableCrashReportOnly knobs are already platform-agnostic. inproccrashreporter.cpp gains __APPLE__ branches for the instruction, stack, and frame pointer accessors. Darwin's ucontext_t::uc_mcontext is a pointer to __darwin_mcontext64, so the Apple branches dereference through ->__ss. On arm64 the arm_thread_state64_get_pc/sp/fp(__ss) accessor macros are used so the registers are stripped of pointer authentication codes on arm64e (identity on arm64). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace the placeholder empty strings for OSVersion and SystemModel in the in-proc crash report with values read via sysctlbyname, matching what createdump's CrashReportWriter::WriteSysctl does: OSVersion <- kern.osproductversion (e.g. '15.1') SystemModel <- hw.model (e.g. 'MacBookPro18,3', 'iPhone13,2') A small WriteSysctlString helper uses a CRASHREPORT_STRING_BUFFER_SIZE stack buffer (ample for both sysctl values) and writes an empty string on failure so the JSON schema remains stable for downstream consumers. sysctlbyname is async-signal-safe and avoids heap allocation, matching the createdump behavior. SystemManufacturer stays hardcoded to 'apple'. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
81500a1 to
b226c7d
Compare
- Cache OSVersion (kern.osproductversion) and SystemModel (hw.model) at Initialize() time instead of querying sysctl from the signal handler. sysctlbyname is not on the POSIX async-signal-safe list, so calling it from a signal-time crash report context was unsafe. Matches the existing m_hostName cache-at-Initialize pattern. - Omit OSVersion/SystemModel from the report when the cache lookup failed and left an empty string, mirroring createdump's WriteSysctl behavior. - NUL-clamp the cached strings to bufferSize-1 to defend against unterminated sysctl returns. - Add explicit <mach/mach.h> include alongside <sys/sysctl.h>; the mach helpers are currently pulled in transitively through <ucontext.h> on Darwin, but the explicit include matches createdump.h and the rest of the PAL conventions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Broaden the HOST_ANDROID guard around the signal-handler managed callstack logging callback to also cover HOST_IOS, HOST_TVOS, and HOST_MACCATALYST so that the same managed stack trace surfaced in Android crash output is also surfaced on the other Apple POSIX targets that opt into the in-process crash reporter. The change covers: - The PAL_SetLogManagedCallstackForSignalCallback registration in ceemain.cpp so EEPolicy::LogManagedCallstackForSignal is wired up. - The EEPolicy::LogManagedCallstackForSignal declaration in eepolicy.h and its implementation in eepolicy.cpp. The PAL signal-handler call sites (PROCLogManagedCallstackForSignal and the underlying PAL hook) were already compiled for all TARGET_UNIX targets, so this change just extends the managed half of the integration. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When a previously-registered signal handler is SIG_DFL, the runtime restores the default action and re-raises so the OS produces its standard crash artifact. On platforms that register a host callback for PAL_SetLogManagedCallstackForSignalCallback (Android, iOS, tvOS, MacCatalyst), invoke that callback first so the managed callstack is written alongside PROCNotifyProcessShutdown and PROCCreateCrashDumpIfEnabled, matching the chained-handler path's behavior. This brings parity for Apple POSIX targets where the previous handler is typically SIG_DFL, which previously caused signal-driven crashes (SIGABRT, SIGSEGV, SIGBUS, SIGFPE, SIGILL) to skip managed-callstack logging. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use arm_thread_state64_get_pc_fptr instead of arm_thread_state64_get_pc when reading the crash thread's instruction pointer. On arm64e devices (real hardware iOS/iPadOS/tvOS) the kernel populates ucontext_t::__pc with the raw PAC-signed value; emitting that into the JSON crash report yields opaque addresses with auth bits set, which are useless for post-mortem symbolication. The _fptr variant returns void* and, on builds with ptrauth enabled, strips the PAC via ptrauth_strip(); on simulator and pre-arm64e builds it reduces to the raw __pc load and is binary-equivalent. This matches the convention already used elsewhere in the codebase for serialized program counters: PAL machexception.cpp and context.cpp use _fptr when populating CONTEXT.Pc, and createdump/threadinfomac.cpp uses _fptr when serializing thread state into the minidump. The internal-only GetInstructionPointer helper in createdump still uses the non-_fptr variant because it is consumed only within the dumping process and never serialized. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.