Skip to content

Commit

Permalink
[java-interop] use RTLD_GLOBAL|RTLD_NOW
Browse files Browse the repository at this point in the history
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...)
  • Loading branch information
jonpryor committed Aug 22, 2020
1 parent d3d1c61 commit 594535c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/java-interop/java-interop-dlfcn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ java_interop_load_library (const char *path, unsigned int flags, char **error)
if ((flags & RTLD_GLOBAL) == RTLD_GLOBAL) strcat (buf, " RTLD_GLOBAL");
if ((flags & RTLD_LOCAL) == RTLD_LOCAL) strcat (buf, " RTLD_LOCAL");
if ((flags & RTLD_NOW) == RTLD_NOW) strcat (buf, " RTLD_NOW");
log_warn (LOG_DEFAULT, "# jonp: java_interop_load_library requested flags=%s; using RTLD_LOCAL|RTLD_NOW", buf);
flags = RTLD_LOCAL | RTLD_NOW;
log_warn (LOG_DEFAULT, "# jonp: java_interop_load_library requested flags=%s; using RTLD_GLOBAL|RTLD_NOW", buf);
flags = RTLD_GLOBAL | RTLD_NOW;
#endif

void *handle = nullptr;
Expand Down

0 comments on commit 594535c

Please sign in to comment.