Skip to content

Commit 0661a9e

Browse files
pepijndevosclaude
andcommitted
[dylink] Normalize library paths to prevent duplicate loading
When a shared library in a subdirectory references a dependency via $ORIGIN/.. rpath, findLibraryFS resolves it to a non-canonical path containing ".." (e.g. "sub/../lib.so"). Since loadDynamicLibrary uses the raw path as the LDSO key, this causes the same library to be loaded twice under different names, running constructors twice. Fix by normalizing libName with PATH.normalize() at the top of loadDynamicLibrary, matching what dlopenInternal already does. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 68c7164 commit 0661a9e

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

src/lib/libdylink.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,8 @@ var LibraryDylink = {
11031103
* @param {Object=} localScope
11041104
*/`,
11051105
$loadDynamicLibrary: function(libName, flags = {global: true, nodelete: true}, localScope, handle) {
1106+
// Avoid duplicate LDSO entries from non-canonical paths (e.g. "sub/../lib.so")
1107+
libName = PATH.normalize(libName);
11061108
#if DYLINK_DEBUG
11071109
dbg(`loadDynamicLibrary: ${libName} handle: ${handle}`);
11081110
dbg('existing:', Object.keys(LDSO.loadedLibsByName));

0 commit comments

Comments
 (0)