Skip to content

Commit

Permalink
[java-interop] try using RTLD_NOW|RTLD_LOCAL
Browse files Browse the repository at this point in the history
Context: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=4002003&view=logs&j=65486226-8c87-5153-e73a-d57909d6ac16&t=d3853860-5663-595d-ac96-d10e64bcf850

The story so far: 2cf8ac9 conjectured that requiring
RTLD_LAZY|RTLD_LOCAL was causing the macOS Designer tests to fail, and
allowed the caller to provide the desired flags *and log them*.

Eventually, we got a log:

	5 [monodroid] # jonp: java_interop_load_library: path=`/Library/Frameworks/Xamarin.Android.framework/Versions/11.1.99.69/lib/xamarin.android/xbuild/Xamarin/Android/lib/host-Darwin/libxa-internal-api.dylib`
	5 [monodroid] # jonp: java_interop_load_library flags= RTLD_NOW

Unfortunately, 2cf8ac9 had a bug in which it didn't check for
RTLD_LOCAL; all we know is that RTLD_NOW was specified, and that
possibly RTLD_LOCAL was specifed (maybe); RTLD_GLOBAL was NOT used.

Also interesting from the log file is what was *missing*: no mentions
of `java_interop_get_symbol_address` were present!

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).

Next test: let's once again "ignore" the `flags` value provided to
`java_interop_load_library()`, and instead always use
RTLD_LOCAL|RTLD_NOW.  Perhaps that's the magic pixie dust needed?
  • Loading branch information
jonpryor committed Aug 22, 2020
1 parent ceada6c commit d3d1c61
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/java-interop/java-interop-dlfcn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@ java_interop_load_library (const char *path, unsigned int flags, char **error)
buf[0] = '\0';
if ((flags & RTLD_LAZY) == RTLD_LAZY) strcat (buf, " RTLD_LAZY");
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 flags=%s", buf);
log_warn (LOG_DEFAULT, "# jonp: java_interop_load_library requested flags=%s; using RTLD_LOCAL|RTLD_NOW", buf);
flags = RTLD_LOCAL | RTLD_NOW;
#endif

void *handle = nullptr;
Expand Down

0 comments on commit d3d1c61

Please sign in to comment.