Skip to content

Commit 594535c

Browse files
committed
[java-interop] use RTLD_GLOBAL|RTLD_NOW
Context: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=4003094&view=logs&j=051336c7-58fc-58df-2c99-9295b706a641&t=cd7280e7-3b2b-5dce-74ae-fa5a799ab1af d3d1c61 failed; RTLD_LOCAL|RTLD_NOW doesn't work. Which *does* make sense given the prior conjecture; > Thus, the next conjecture: whatever codepath was trying to lookup > `java_interop_jnienv_get_java_vm` within 2cf8ac9 *isn't* using > `java_interop_get_symbol_address()` to do so, and is instead relying > on the normal dynamic linker (somehow). RTLD_LOCAL means "you can only use the handle returned from dlopen() along with dlsym() to find symbols", and since our current conjecture is that "something else" is "somehow" obtaining these symbols, then therefore the .so *must* be loaded globally. RTLD_GLOBAL is also the default, so the prior log that mentioned RTLD_NOW was implicitly using RTLD_GLOBAL. Confirm the current theory: we need global lookup, so use RTLD_GLOBAL. (I'd also consider trying RTLD_LAZY, but I think RTLD_NOW is closer to Windows' LoadLibrary() semantics anyway...)
1 parent d3d1c61 commit 594535c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/java-interop/java-interop-dlfcn.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ java_interop_load_library (const char *path, unsigned int flags, char **error)
106106
if ((flags & RTLD_GLOBAL) == RTLD_GLOBAL) strcat (buf, " RTLD_GLOBAL");
107107
if ((flags & RTLD_LOCAL) == RTLD_LOCAL) strcat (buf, " RTLD_LOCAL");
108108
if ((flags & RTLD_NOW) == RTLD_NOW) strcat (buf, " RTLD_NOW");
109-
log_warn (LOG_DEFAULT, "# jonp: java_interop_load_library requested flags=%s; using RTLD_LOCAL|RTLD_NOW", buf);
110-
flags = RTLD_LOCAL | RTLD_NOW;
109+
log_warn (LOG_DEFAULT, "# jonp: java_interop_load_library requested flags=%s; using RTLD_GLOBAL|RTLD_NOW", buf);
110+
flags = RTLD_GLOBAL | RTLD_NOW;
111111
#endif
112112

113113
void *handle = nullptr;

0 commit comments

Comments
 (0)