Repository navigation
Description
Description
NativeAOT-published apps crash with SIGSEGV at startup on OpenHarmony (HarmonyOS NEXT, arm64) after #132787 ("Include unboxing stubs in r2r images", merged 2026-09-02, R2R version bump 27.0 -> 27.1). The crash is in the AOT app's module initialization, not in R2R/crossgen2 image loading: TypeManager::GetModuleSection receives a null module pointer.
We verified the regression by reverting #132787 (R2R back to 27.0) and rebuilding the NativeAOT toolchain + runtime pack — the identical app then runs cleanly. Important caveat: we have only verified this on OpenHarmony (aarch64). We have NOT verified ios/wasm or any other platform — #132787's stated target platforms are ios/wasm, so the regression may affect them too and needs maintainer attention there.
Environment
- .NET 11.0.0-rc.1.26451.109 (upstream-merged build, includes Include unboxing stubs in r2r images #132787)
- OpenHarmony (HarmonyOS NEXT 7.0.0, HongMeng kernel 1.13.0), aarch64
- NativeAOT publish:
dotnet publish -r ohos-arm64 -p:PublishAot=true - App: minimal (libc write(2) only, no managed API calls) — deterministic 100% repro
Repro
dotnet publish -r ohos-arm64 -p:PublishAot=truewith the .NET 11 rc.1 26451.109 toolchain (which includes Include unboxing stubs in r2r images #132787 / R2R 27.1)- Run the produced app on the device
- Result: SIGSEGV (exit 139), 100% reproducible
Crash signature
Signal: SIGSEGV, si_code=1 (SEGV_MAPERR), si_addr=0x8
Stack:
_start_c -> main
-> S_P_CoreLib_Internal_Runtime_CompilerHelpers_StartupCodeHelpers__InitializeModules
-> TypeManager::GetModuleSection(ReadyToRunSectionType, int*) (faulting)
Faulting instruction (GetModuleSection entry):
ldr x10, [x0, #8] ; x0 == NULL (TypeManager/module ptr) -> reads 0x8
InitializeModules hands GetModuleSection a null TypeManager/module pointer in apps compiled with the post-#132787 toolchain. The same source compiled with the 26451.1 (R2R 27.0) toolchain runs fine.
Root-cause verification (device matrix, minimal app)
| ilc (compiler) | NativeAOT runtime pack | result |
|---|---|---|
| 109 split (R2R 27.1, includes #132787) | 109 (27.1) | SIGSEGV exit 139 (stable) |
109 split rebuilt with git revert 36ef18696f8 (R2R 27.0) |
26451.1 pack (27.0) | exit 0 |
| 109 split rebuilt with revert (R2R 27.0) | rebuilt pack (27.0) | exit 0, stable 3/3 |
Output size delta: 27.0 build ~977KB vs 27.1 crashing build ~1.03MB (-57KB, consistent with removing the BoxedTypes.cs unboxing-stub support added by #132787).
Full functional app (GC, LINQ, exceptions, reflection, Math, Dictionary, DateTime, Task.Run, Guid) publishes and runs correctly with the reverted (27.0) toolchain — all 9 checks pass on device.
Suspected mechanism
#132787 changed the NativeAOT module metadata layout (src/coreclr/nativeaot/Runtime/inc/ModuleHeaders.h, src/coreclr/tools/Common/Internal/Runtime/ModuleHeaders.cs) for the new unboxing-stub InstanceMethodEntryPoints encoding, and bumped the R2R version because "an older runtime, whose SigMatchesMethodDesc doesn't check the unboxing bit, could incorrectly match a normal method with an unbox stub". The device crash is in startup module-table walk (InitializeModules -> GetModuleSection) — consistent with the runtime and the freshly compiled app disagreeing on the module metadata format (runtime built from the same tree, so this is a codegen/format inconsistency introduced by the change rather than a version skew).
Scope caveat (important)
- Verified only on OpenHarmony arm64. The crash is in runtime-agnostic NativeAOT startup code paths (module metadata consumption shared by all NativeAOT targets), so ios/wasm/maccatalyst NativeAOT apps built with a post-Include unboxing stubs in r2r images #132787 toolchain may be affected — we cannot test those platforms from this environment.
- The R2R (crossgen2) image path itself (CoreLib R2R via official crossgen2) works on-device; the regression is specific to NativeAOT app startup.
Ask
- Please investigate whether the Include unboxing stubs in r2r images #132787 module-metadata/unboxing-stub change breaks NativeAOT app startup on ios/wasm (the PR's target platforms) and other NativeAOT targets.
- If confirmed, consider reverting or fixing Include unboxing stubs in r2r images #132787 (the fix may need to preserve the unboxing-stub feature while keeping startup metadata consumption compatible).
Additional context
- Tracking issue for the OpenHarmony port: Add OpenHarmony (HarmonyOS) support to the .NET runtime #132866
- Include unboxing stubs in r2r images #132787 commit: 36ef186
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity
dotnet-policy-service commentedon Sep 5, 2026
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib
See info in area-owners.md if you want to be subscribed.
springmin commentedon Sep 5, 2026
Note
The device verification described above was performed with AI assistance (agent tooling) under the reporter's direction; the crash data (SIGSEGV si_addr, stack frames, A/B matrix results) was captured directly from the device.
springmin commentedon Sep 5, 2026
Additional binary-level evidence from the crashing (27.1) vs working (27.0) app outputs (identical minimal source, only the #132787 revert differs) — may help localize the null-module:
Section deltas (llvm-objdump -h), crash build minus 27.0 build:
.rodata: 27.1 0x2abfd → 27.0 0x271ad (-0x3a50 / ~15KB — module/ReadyToRun metadata region).data: -0x1f8,.bss: -0x400,.text: ~equal (-0xe4)TypeManagerconstruction walks the module list and callsGetModuleSectionper module; in the 27.1 build the list handed toInitializeModulescontains a null entry. The +15KB.rodatadelta is consistent with #132787's added unboxing-stub metadata (InstanceMethodEntryPoints entries sharing the wrapped method's token/instantiation, flaggedREADYTORUN_METHOD_SIG_UnboxingStub).Could the NativeAOT team please verify whether ios/wasm (the platforms #132787 targeted) also hit this? We can only test OpenHarmony; if the unboxing-stub module walk is platform-independent the same null-TypeManager failure would appear there. Happy to run additional instrumented builds or provide the app binaries if useful.
jkotas commentedon Sep 5, 2026
cc @BrzVlad
BrzVlad commentedon Sep 7, 2026
I'm wondering if this is just a versioning problem on your side. I'm not seeing any related ios failures on CI following the merge and your error sounds like some mismatch between the runtime and ilc compiled modules. Also, some of the conclusions are weird, for example the difference in size in binaries for nativeot between 27.0 and 27.1. The unboxing stub PR only added their emission inside r2r images, there should be no changes to ILC output, aside from the version bump, so r2r and nativeaot just have the versions in sync. The AI also suggests that format change was added, by adding these methods in
InstanceMethodEntryPointstable, but this is also R2R only, so I'm wondering if AI followed a wrong assumption in its investigation.MichalStrehovsky commentedon Sep 7, 2026
I think this is just mismatched/stale binaries being used. Make sure to do a clean rebuild of everything.
Below is from AI:
This failure mode is consistent with a ReadyToRun version mismatch, without requiring an actual metadata-layout incompatibility.
TypeManager::Createrequires an exact match of both major and minor versions and returnsnullptrif either differs.RhpCreateTypeManagerpropagates that null handle, and startup immediately uses it inRhGetModuleSectionwithout checking for failure. That fits the reported nullTypeManagerand access at0x8.At commit
36ef18696f85, both the compiler-side constants inModuleHeaders.csand the native runtime constants inModuleHeaders.hare 27.1, so those source definitions agree. However, building from the same tree does not necessarily rule out stale compiler binaries, native libraries, or cached runtime-pack artifacts.Could you check the incoming header’s
MajorVersionandMinorVersioninTypeManager::Create, compared with the values the actually linked native runtime checks? That would directly confirm or eliminate version skew as the explanation..dotnet-policy-service commentedon Sep 7, 2026
This issue has been marked
needs-author-actionand may be missing some important information.springmin commentedon Sep 8, 2026
@BrzVlad @MichalStrehovsky — thank you both for the analysis; the version-mismatch hypothesis is reasonable and I want to clarify what we did and did not control, and what I'll do to close this out properly.
Context: this was found while bringing up the first OpenHarmony (HarmonyOS) port of the runtime. The port tracks upstream main and merges changes continuously — #132787 (36ef186, R2R 27.1) came in via a routine upstream merge on 09-02. The cross-build toolchain (NDK-based, no official CI leg yet) is still being assembled; I am in the middle of standing up the automated build script + CI pipeline. The verification environment is not clean: it mixes several locally built ILCompiler/NativeAOT packs, a stock crossgen2 from a different build, and manually cache-swapped package slots. So stale or mismatched components are entirely plausible, and I take that seriously.
What was controlled in the A/B test: for the round-17 comparison I attempted to isolate the variable — the 27.1 (crash) and 27.0 (working) packages were built from the same 109-baseline ilc.dll shape, differing only by the 36ef revert (readytorun.h MINOR 0x1→0x0 + unboxing-stub removal). That said, this controlled the ilc side only; the full runtime ↔ toolchain ↔ crossgen2 version alignment across the whole toolchain was not re-established from a clean build, which is exactly the gap you both pointed at.
TypeManager::Create's exact major+minor match requirement returning null on mismatch fits the observed null TypeManager / access at 0x8 perfectly.Plan: I'm finishing the automated build/CI setup first (it's the prerequisite for a trustworthy clean rebuild). Once that is in place I will do a full clean rebuild of everything from current upstream main (including #132787) — runtime, ilc, crossgen2, packs, all from one version-aligned source — and re-run the device repro. I'll report back here with the result: if the SIGSEGV reproduces on a clean 27.1 toolchain, it's a real regression needing a proper fix (and I'll note again that #132787 targets ios/wasm, which I cannot verify from this port); if it does not, I'll close this out as a toolchain-alignment issue on my side.
Keeping this issue open until the clean-rebuild result is available.
Note
This comment was drafted with AI assistance (agent tooling) under the reporter's direction; the technical content was reviewed by the reporter before posting.
Add crossgen2_version input to ohos-full-build (R2R version alignment)
jkotas commentedon Sep 8, 2026
This is clearly a version mismatch. It can be closed.
springmin commentedon Sep 8, 2026
@MichalStrehovsky @BrzVlad — the clean-rebuild verification is done, and the result confirms your assessment.
Result: the SIGSEGV does NOT reproduce with a version-aligned 27.1 toolchain. A full-function NativeAOT app (GC/LINQ/exception/reflection/math/dict/async/guid) published from the 27.1 branch (36ef reinstated, R2R MINOR 0x0001) with matching 27.1 ilc/ILCompiler/NativeAOT packs runs to completion on device (exit 0, output file verified). Same app shape that crashed in the round-17b report now passes.
Root cause (as you both diagnosed): the round-17b "27.1 crash" build had paired the 27.1 runtime with a stock crossgen2 from 11.0.0-rc.1.26427.131 — built before #132787 merged — so it emitted R2R 27.0 CoreLib images against a 27.1 runtime.
TypeManager/R2R version matching is exact (major+minor), the mismatch produced the null TypeManager and the access at 0x8. The A/B "27.0 works / 27.1 crashes" delta in round-17b was actually runtime-version ↔ crossgen2-version alignment, not the 36ef code change itself.What I did: full clean CI cross-build (runtime/aspnetcore/sdk, sdk-ohos workflow) from a branch that reinstates 36ef (runtime R2R 27.1), with the stock crossgen2 bumped to 11.0.0-rc.1.26451.109 (post-36ef official build) via a new workflow input, then device AOT publish + run of the repro app using the 27.1 packs.
Two follow-ups I'll note separately:
ILCompiler.TypeSystem.dll(GetPrimitiveType stripped) and an incomplete framework layout — it needed on-device repair to run. That's a fork packaging bug (assemble-ilc-pack.py), not an upstream issue, but I'll fix the pack assembly so future builds are self-contained.Closing this out as resolved (toolchain alignment, not a 36ef regression) — happy to reopen with evidence if a real ios/wasm impact ever shows up, but I have no way to verify those platforms from this port.
Note
This comment was drafted with AI assistance (agent tooling) under the reporter's direction; device run results were captured directly from the device.
Fix ohos-arm64 ilc split pack: PublishTrimmed=false (ILLink strips Ge…
Reinstate R2R 27.1 (unboxing stubs, 36ef) on feature branch
Default crossgen2_version to 26451.109 (post-36ef, R2R 27.1)
assemble-ilc-pack: overlay framework files from runtime pack nupkg
docs: PR plan re-review — add N14-N16, fork-local-only notes, status …