fix(pj_plugins): entry-point symbol provenance + modern platform loaders (0.23.0) - #175
Merged
Merged
Conversation
…ers (0.23.0) Resolve pj_plugin_abi_version and the PJ_get_*_vtable entry points strictly from the candidate DSO: dladdr + filesystem::equivalent identity on Linux, RTLD_FIRST on macOS, module-scoped GetProcAddress unchanged on Windows. Replace LoadLibraryExA + LOAD_WITH_ALTERED_SEARCH_PATH with LoadLibraryExW + DLL_LOAD_DIR|DEFAULT_DIRS in both loaders (CWD and PATH no longer resolve dependencies), make loader signatures path-typed with internal absolute-path normalization, and delete the ACP/UTF-8 contract mismatch. Add the single-open adoption API (non-owning adopt, loadFromHandle on all four families, handle-based inspection, provenance- checked family enumeration) for the admission helper. Standardize plugin install rpaths ($ORIGIN / @loader_path). Tests: two-DSO provenance fixtures in both directions, Unicode paths, CWD/PATH decoys. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0165qLfnJYSYb51NQMdPidZr
Record the normalized absolute dlopen path and prove provenance against it byte-first (deferred dialog resolution survives file deletion and CWD changes); restore the UTF-8 contract of the narrow native-parser API on Windows; normalize native-parser paths to absolute; verify Windows provenance via GetModuleHandleExW(FROM_ADDRESS) so PE forwarded exports are rejected; route native-parser symbols through the shared provenance resolver with RTLD_FIRST on macOS. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0165qLfnJYSYb51NQMdPidZr
…rded provenance paths The forwarder fixture uses true forwarder syntax against the donor DLL basename; load-time identity records both the exact absolute loader argument and its weakly_canonical form so dyld's realpath dli_fname byte-matches without live filesystem access (deletion test now also loads through a symlinked directory to reproduce the macOS shape on Linux). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0165qLfnJYSYb51NQMdPidZr
…f entry MSVC LINK parses the .def EXPORTS forwarder entry as an internal-name alias and demands a local definition (LNK2001 in two CI rounds); the /export linker-directive form emits a true forwarder. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0165qLfnJYSYb51NQMdPidZr
…emantics Rename instead of delete the mapped candidate on Windows (deletion of a mapped image is impossible there; deferred resolution must survive the path vanishing either way), and emit the real dependency fixture into its own directory so LOAD_LIBRARY_SEARCH_APPLICATION_DIR cannot resolve it from beside the test executable and defeat the decoy-only case. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0165qLfnJYSYb51NQMdPidZr
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.
Implements the SDK half of PJ4 marketplace plan row 12b.
What
pj_plugin_abi_versionand everyPJ_get_*_vtableentry point must resolve from the candidate DSO itself. POSIX:dladdrcompared byte-first against the recorded absolute dlopen path (zero filesystem access on the fast path;std::filesystem::equivalentfallback), so deferred dialog resolution survives file deletion and CWD changes. macOS addsRTLD_FIRST. Windows:GetModuleHandleExW(FROM_ADDRESS)closes the PE forwarded-export hole.LoadLibraryExW+LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR|DEFAULT_DIRSin both loaders — CWD andPATHno longer resolve plugin dependencies. Loader signatures are path-typed with internal absolute normalization; the native-parser narrow API keeps its strict UTF-8 contract.loadFromHandleon all four families (validation chain identical toload()), handle-basedinspectPluginDso, provenance-checked family enumeration.INSTALL_RPATH$ORIGIN/@loader_path(build rpaths untouched).Verification
EntryPointSymbolResolvedFromDependencyIsRejected(first two-DSO fixture in the repo, both weak-symbol directions),DependencySearchExcludesCwdAndPath,UnicodeExtensionPathLoadsOnWindows,DialogVtableSurvivesCandidateFileDeletion,DialogVtableSurvivesCwdChangeAfterRelativeLoad,NativeParserNarrowPathIsUtf8, Windows-onlyForwardedEntryPointIsRejected.abi/baseline.abiuntouched; zero behavior change for well-formed plugins (declined alternatives documented: noRTLD_NODELETEcontract, noRTLD_DEEPBIND, nodlmopen).Note: open PR #173 also stages
VERSION0.23.0 — whichever lands second rebases its version/changelog heading (the release workflow hard-fails on tag/VERSION mismatch, so this cannot ship wrong).🤖 Generated with Claude Code
https://claude.ai/code/session_0165qLfnJYSYb51NQMdPidZr