Repository navigation
Conversation
dyld reuses an already-loaded image by install name only for @rpath/ dependencies (Loader.cpp:802-816) and evaluates other dependency forms against their expanded path for each loader. When multiple images in different directories depend on @loader_path/ libraries sharing an install name, checking loaded images before candidate expansion caused subsequent loaders to bind to the first loaded image's copy or appear resolved when their own copy was absent. Limit byInstallName registration and lookup to install names that start with @rpath/, leaving caller-relative and literal dependencies to expand and evaluate their own candidate paths. Signed-off-by: Vinícius DS Andrade <95101505+viniciusdsandrade@users.noreply.github.com>
Assert that multiple images depending on @loader_path/ libraries with the same install name do not reuse already-loaded images across loaders. When the second loader's helper is absent, its candidate path is absent and dyld reports required-load-unresolved; when both helpers exist, each loader resolves to its own directory. Signed-off-by: Vinícius DS Andrade <95101505+viniciusdsandrade@users.noreply.github.com>
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Owner
|
@greptileai review |
Contributor
|
This PR is set for a Plus review. TREX isn't supported with Plus or Apex reviews yet, so Greptile reviews this PR at Base while TREX is on. |
Contributor
|
3 tasks done
2 tasks done
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.
Summary
When multiple images in different directories depend on
@loader_path/libraries sharing an install name (for example, plugins or isolated helpers bundling@loader_path/libhelper.dylib), dyld dependency resolution checkedcontext.byInstallNamebefore candidate path expansion. BecausebyInstallNamewas populated for any install name, the second loader erroneously bound to the first loader's resolved copy or appeared resolved even when its own copy was absent.Apple dyld (
Loader.cpp:802-816) reuses already-loaded images by install name only for@rpath/dependencies; caller-relative and literal dependencies are evaluated against their expanded candidate paths for each loader. LimitbyInstallNameregistration and lookup to install names starting with@rpath/.No existing issue covers this.
Problem and expected behavior
In
src/domain/apple/dylibResolution.ts,resolveDependencyconsultscontext.byInstallName.get(dependency.install_name)before expanding candidate paths. WhentraceProcessloads an image whose slice has an install name, it registerscontext.byInstallName.set(slice.install_name, image).Consider an application bundling two plugins in separate directories:
Contents/PlugIns/A/pluginA.dylibdepending on@loader_path/libhelper.dylibContents/PlugIns/B/pluginB.dylibdepending on@loader_path/libhelper.dylibWhen
pluginA.dylibloads, REA resolves@loader_path/libhelper.dylibtoContents/PlugIns/A/libhelper.dyliband registers@loader_path/libhelper.dylib -> Contents/PlugIns/A/libhelper.dylibinbyInstallName. WhenpluginB.dylibis later evaluated,resolveDependencyfinds@loader_path/libhelper.dylibinbyInstallNameand immediately bindspluginB's dependency toContents/PlugIns/A/libhelper.dylibwithout expanding candidate paths relative topluginB's directory. IfContents/PlugIns/B/libhelper.dylibis absent, REA reports the dependency as resolved rather than emitting arequired-load-unresolvedfinding.Expected behavior: dyld reuses already-loaded images by install name only for
@rpath/dependencies.@loader_path/,@executable_path/, and literal dependencies expand candidate paths for each loader; identical images reached through identical paths are deduplicated once resolved.Change and scope
src/domain/apple/dylibResolution.ts: limitcontext.byInstallNamelookup inresolveDependencyto dependencies whoseinstall_namestarts with@rpath/. Limitcontext.byInstallName.setregistration intraceProcessto slices whoseinstall_namestarts with@rpath/.docs/apple-application-analysis.mdandsrc/domain/apple/dylibResolutionFindings.ts: update the documentation and limitation text to state that already-loaded reuse by install name applies to@rpathrequests.src/domain/apple/dylibResolution.test.ts: add regression tests asserting that@loader_pathdependencies across isolated directories do not reuse already-loaded images by install name, reportingrequired-load-unresolvedwhen the second helper is absent and resolving to each loader's own directory when both exist.Contract and boundary impact
src/domain/apple/dylibResolution.ts.trace_dylib_resolutioncandidate paths and resolution status reflect each loader's own directory for@loader_path/dependencies.docs/public/product-catalog.json), package, or installation impact: none.Evidence and regression coverage
src/domain/apple/dylibResolution.test.tsadds tests underdescribe("loader-relative dylib resolution")verifying that@loader_path/dependencies in isolated directories do not reuse already-loaded images by install name, both when the second loader's helper is absent and when each loader has its own helper.pluginB's dependency resolves toContents/PlugIns/A/libhelper.dylibeven whenContents/PlugIns/B/libhelper.dylibis absent, and norequired-load-unresolvedfinding is produced.required-load-unresolvedfinding when the target directory lacks the dependency.For evidence-bearing changes:
Validation performed
Compatibility, safety, and release
Review checklist
type(scope): outcome.