dukeify / fake-jni

An implementation of the JNI and JVMTI with support for direct interaction between natively registered classes and JVM objects.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fix intermittent "Tried to start JVM instance twice!" bug

Matthewacon opened this issue · comments

The default example should yield the following output:

╰─❱ ./examples
DEBUG: '(embedded)' contains no JNI linkage
DEBUG: '(embedded)' contains no Agent linkage
WARNING: Neither JNI nor Agent hooks were found for library: '(embedded)'!
DEBUG: Created library: '(embedded)'
DEBUG: Registered library: '(embedded)'
FATAL: VM encountered an uncaught exception with message:
No classes define the default Java entry point: 'main([Ljava/lang/String;)V'!

however, seemingly at random, it will instead raise the runtime exception FATAL: Tried to start JVM instance twice!, which should only happen when Jvm::start() is invoked on a thread that is already attached to a running JVM instance. ASAN and UBSAN report no issues in either execution trace. There is an example of the problematic output below.

Note: The example output contains another bug related to recursive unwinding. See #96.

See the log here.

This is probably related: (as of d0e05d4)

../src/fake-jni/jvm/jvm.cpp:448:7: runtime error: load of value 32, which is not a valid value for type 'bool'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/fake-jni/jvm/jvm.cpp:448:7 in