Resolve a delay loaded library's dependencies from its own directory - #22
Merged
Conversation
LoadLibraryA locates the named library by absolute path but resolves that library's own dependencies through the ambient search order, which never includes the directory it was loaded from. A bundled library that depends on a sibling then dies with a 0xC06D007E delay load exception once the process has no current directory or PATH entry that happens to cover it.
kasperisager
approved these changes
Aug 20, 2026
kasperisager
left a comment
Contributor
There was a problem hiding this comment.
Wrong radio button 🤦
This was referenced Aug 20, 2026
Merged
Closed
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.
bare__module_loadbuilds an absolute path to a library installed next to the addon and callsLoadLibraryA. That finds the named library, but its dependencies resolve through the ambient search order, which excludes the directory it came from. A bundled library depending on a sibling is found only if the current directory orPATHcovers it. When neither does - always, for a packaged MSIX app - the delay load helper raises0xC06D007Eand the process exits with nothing to catch.macOS and Linux are unaffected: the addon carries an
@loader_path/$ORIGINrunpath, and PE has no equivalent.The fix is
LoadLibraryExAwithLOAD_LIBRARY_SEARCH_DLL_LOAD_DIR, which the loader also applies to that library's dependencies, plusLOAD_LIBRARY_SEARCH_DEFAULT_DIRS. That drops the current directory andPATHfrom the search;LOAD_WITH_ALTERED_SEARCH_PATHis the additive alternative.test/fixtures/transitive-dependencycovers whatruntime-dependencymisses: it installs a library but never references it. On win32-arm64 the process exits0xC06D007Ebefore the change and the suite is 6/6 after; also 6/6 on darwin-arm64.Found from holepunchto/bare-collabora#28.