[net11.0] [runtime] Register host_runtime_contract callbacks so CoreCLR finds System.Private.CoreLib.dll#25562
Conversation
…ystem.Private.CoreLib.dll dotnet/runtime#128278 (.NET 11 preview 5) gated the BindToSystem CoreLib fallback behind `Bundle::AppIsBundle () && Bundle::AppBundle->HasExtractedFiles ()`. macios doesn't bundle assemblies and never registered `bundle_probe` nor a `BUNDLE_EXTRACTION_PATH` property, so the gate fails and CoreCLR can't locate `System.Private.CoreLib.dll` (which lives at the app bundle root, not next to `libcoreclr.framework/libcoreclr`). The app aborts in `xamarin_vm_initialize` with "Failed to initialize the VM". Fix: register a no-op `bundle_probe` so `Bundle::AppBundle` is non-null, and answer `BUNDLE_EXTRACTION_PATH` from `get_runtime_property` with the directory that actually contains CoreLib (app bundle root, then `.xamarin/<RID>`, matching the TPA probe order). The fallback then finds CoreLib and the VM initializes. Fixes #25542. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the Apple native CoreCLR host shim to provide the host_runtime_contract callbacks CoreCLR now relies on (in .NET 11 preview 5+) to locate System.Private.CoreLib.dll via the bundle/extraction fallback, fixing CoreCLR startup failures on iOS devices where libcoreclr and CoreLib are not colocated.
Changes:
- Register a no-op
bundle_probecallback so CoreCLR considers the app “bundled” for the fallback gate. - Implement
get_runtime_propertyto answerHOST_PROPERTY_BUNDLE_EXTRACTION_PATHwith the directory that actually containsSystem.Private.CoreLib.dll(bundle root, then.xamarin/<RID>). - Wire these callbacks into the
host_runtime_contractpassed throughHOST_RUNTIME_CONTRACTduringxamarin_vm_initialize.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #0a31d6e] Build passed (Detect API changes) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #0a31d6e] Build passed (Build packages) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #0a31d6e] Build passed (Build macOS tests) ✅Pipeline on Agent |
🔥 [CI Build #0a31d6e] Test results 🔥Test results❌ Tests failed on VSTS: test results 3 tests crashed, 24 tests failed, 132 tests passed. Failures❌ dotnettests tests (MacCatalyst)🔥 Failed catastrophically on VSTS: test results - dotnettests_maccatalyst (no summary found). Html Report (VSDrops) Download ❌ linker tests (macOS)🔥 Failed catastrophically on VSTS: test results - linker_macos (no summary found). Html Report (VSDrops) Download ❌ monotouch tests (iOS) [attempt 2]24 tests failed, 0 tests passed.Failed tests
Html Report (VSDrops) Download ❌ monotouch tests (MacCatalyst) [attempt 2]🔥 Failed catastrophically on VSTS: test results - monotouch_maccatalyst (no summary found). Html Report (VSDrops) Download Successes✅ cecil: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Sonoma (14): All 5 tests passed. [attempt 2] Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
|
Merging, this targets another PR, and the problem this PR is supposed to fix looks fixed. |
c6fabd7
into
darc-net11.0-d4fe64b2-8391-403d-bbd7-5e3371f43b46
…LR finds System.Private.CoreLib.dll (#25562) ### Description When CoreCLR starts, AssemblyBinderCommon::BindToSystem loads System.Private.CoreLib.dll. It first looks next to libcoreclr, and if that fails it runs a fallback path. In .NET 11 preview 5, dotnet/runtime#128278 changed the fallback to read CoreLib from the single-file bundle's extraction directory, and gated it on Bundle::AppIsBundle() && Bundle::AppBundle->HasExtractedFiles(). Those two flags are set from the host. AppIsBundle() requires the host to register a bundle_probe callback on host_runtime_contract, and HasExtractedFiles() requires the host to return a path from the BUNDLE_EXTRACTION_PATH runtime property. The primary lookup fails on Apple mobile device, because libcoreclr ships inside Frameworks/libcoreclr.framework/libcoreclr while System.Private.CoreLib.dll lives at the app bundle root, so CoreLib is never next to libcoreclr. ### Fix Register a no-op bundle_probe and provide BUNDLE_EXTRACTION_PATH with the directory containing System.Private.CoreLib.dll (app bundle root, then .xamarin/<RID>), so the gate passes and BindToSystem resolves CoreLib from that directory. Fixes #25542 --------- Co-authored-by: Milos Kotlar <miloskotlar@github.com> Co-authored-by: Copilot <223556219+Copilot@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>
Description
When CoreCLR starts, AssemblyBinderCommon::BindToSystem loads System.Private.CoreLib.dll. It first looks next to libcoreclr, and if that fails it runs a fallback path. In .NET 11 preview 5, dotnet/runtime#128278 changed the fallback to read CoreLib from the single-file bundle's extraction directory, and gated it on Bundle::AppIsBundle() && Bundle::AppBundle->HasExtractedFiles().
Those two flags are set from the host. AppIsBundle() requires the host to register a bundle_probe callback on host_runtime_contract, and HasExtractedFiles() requires the host to return a path from the BUNDLE_EXTRACTION_PATH runtime property. The primary lookup fails on Apple mobile device, because libcoreclr ships inside Frameworks/libcoreclr.framework/libcoreclr while System.Private.CoreLib.dll lives at the app bundle root, so CoreLib is never next to libcoreclr.
Fix
Register a no-op bundle_probe and provide BUNDLE_EXTRACTION_PATH with the directory containing System.Private.CoreLib.dll (app bundle root, then .xamarin/), so the gate passes and BindToSystem resolves CoreLib from that directory.
Fixes #25542