[runtime] Register host_runtime_contract callbacks so CoreCLR finds System.Private.CoreLib.dll#25561
Closed
kotlarmilos wants to merge 4 commits into
Closed
[runtime] Register host_runtime_contract callbacks so CoreCLR finds System.Private.CoreLib.dll#25561kotlarmilos wants to merge 4 commits into
kotlarmilos wants to merge 4 commits into
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>
Member
|
@kotlarmilos I created a PR from your branch into the maestro PR that brings this change from dotnet/runtime, that way we can be sure it works: #25562 |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the CoreCLR startup path so the host runtime contract can satisfy CoreCLR’s new CoreLib fallback lookup requirements on Apple app bundle layouts.
Changes:
- Adds CoreCLR host contract callbacks for
bundle_probeandBUNDLE_EXTRACTION_PATH. - Computes the directory containing
System.Private.CoreLib.dllfrom the app bundle root or.xamarin/<RID>. - Registers the new callbacks in
xamarin_vm_initialize.
Show a summary per file
| File | Description |
|---|---|
runtime/runtime.m |
Adds CoreCLR host runtime contract callbacks and wires them into VM initialization. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 3
| // Bundle::AppIsBundle () && Bundle::AppBundle->HasExtractedFiles (). Register a no-op | ||
| // bundle_probe so AppBundle is non-null, and answer BUNDLE_EXTRACTION_PATH with the | ||
| // directory containing System.Private.CoreLib.dll so the fallback finds it. | ||
| static bool xamarin_coreclr_bundle_probe(const char *path, int64_t *offset, int64_t *size, int64_t *compressed_size) |
Comment on lines
+2471
to
+2476
| static bool xamarin_coreclr_bundle_probe(const char *path, int64_t *offset, int64_t *size, int64_t *compressed_size) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| static const char *xamarin_compute_corelib_directory(void) |
| return cached; | ||
| } | ||
|
|
||
| static size_t xamarin_coreclr_get_runtime_property(const char *key, char *value_buffer, size_t value_buffer_size, void *contract_context) |
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>
Member
Author
|
Closing in favor of #25562 |
Collaborator
🔥 [PR Build #$(fix_c] Build failed (Build packages) 🔥Build failed for the job 'Build packages' (with job status 'Failed') Pipeline on Agent |
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.
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