Use bundle extraction path for CoreLib fallback in BindToSystem#128278
Open
elinor-fung wants to merge 2 commits into
Open
Use bundle extraction path for CoreLib fallback in BindToSystem#128278elinor-fung wants to merge 2 commits into
elinor-fung wants to merge 2 commits into
Conversation
When the primary lookup of System.Private.CoreLib.dll in the system directory fails, the binder previously scanned the TRUSTED_PLATFORM_ASSEMBLIES list (queried from the CLR config knobs) for a matching simple name. The case this fallback was originally added for (PR dotnet#42435) is the single-file app with extracted contents (IncludeAllContentForSelfExtract): CoreCLR is statically linked into the host executable so SystemDirectory points at the host directory, but the extracted CoreLib lives in the bundle extraction directory. Look directly in the bundle extraction directory in that case instead of scanning the TPA list. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
Tagging subscribers to this area: @agocke |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates CoreCLR's system assembly binding fallback for extracted single-file bundles: instead of scanning TRUSTED_PLATFORM_ASSEMBLIES when System.Private.CoreLib.dll is not beside CoreCLR/the host, it probes the known bundle extraction directory directly.
Changes:
- Removes the
configuration.hdependency previously needed for reading the TPA list. - Replaces the TPA-list scan fallback with
Bundle::AppBundle->ExtractionPath()when the app is a bundle with extracted files. - Preserves the primary lookup and tracing flow for the normal system-directory/bundle-probe paths.
Show a summary per file
| File | Description |
|---|---|
src/coreclr/binder/assemblybindercommon.cpp |
Updates BindToSystem CoreLib fallback logic for extracted single-file bundles. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 0
AaronRobinsonMSFT
approved these changes
May 16, 2026
On targets where corerun enables the external assembly probe (browser-wasm), the runtime invokes the probe with the simple assembly name during BindToSystem (e.g. "System.Private.CoreLib.dll"). The probe previously only populated its core_root/core_libs search paths in APP_ASSEMBLIES=EXTERNAL mode, so in default PROPERTY mode the probe couldn't resolve a simple name when BrowserHost_ExternalAssemblyProbe (which reads from FS by path) failed. Always populate s_core_root_path/s_core_libs_path when the external probe is enabled, regardless of APP_ASSEMBLIES mode. This lets the probe satisfy the BindToSystem CoreLib lookup on browser-wasm where CoreCLR is statically linked into corerun and SystemDomain::SystemDirectory() is empty. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
3 tasks
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.
When the primary lookup of
System.Private.CoreLib.dllin the system directory (the directory CoreCLR was loaded from) fails, the binder previously fell back to scanning theTRUSTED_PLATFORM_ASSEMBLIESvalue for a matching simple name. This fallback was originally added in #42435 specifically for the self-contained single-file app with extracted contents (IncludeAllContentForSelfExtract=true) case - CoreCLR is statically linked into the host executable, soSystemDirectorypoints at the host directory, but the extracted CoreLib lives in the bundle extraction directory.Look directly in the bundle extraction directory in that case instead of scanning the TPA list.
cc @dotnet/appmodel @AaronRobinsonMSFT
For a
Hello, World!self-contained single-file app published withIncludeAllContentForSelfExtract=true, the framework's deps.json hadSystem.Private.CoreLibat runtime asset position 98 of 182. Per process startup, the old fallback did:StackSStringcopy of the TPA listoutPathSString perGetNextTPAPathiterationsimpleNameSString per iterationNormalize, comparisons, etc.)Measured via a
DYLD_INSERT_LIBRARIESmalloc/calloc/realloc interposer over 5 fresh runs each (osx-arm64 Release):The savings scale with TPA list size and CoreLib's position in it: roughly
1 large (TPA copy) + 2k small allocationsfor k entries scanned before CoreLib.