Name: rl43681 Date: 07/31/2000
java version "1.2.2"
Classic VM (build 1.2.2_006, green threads, nojit)
Note: This problem occurs in 1.2.2-L and 1.3.0beta-refresh also in exactly the
same way as described below.
The simple "invoke.c" program fails on RedHat Linux 6.1 as follows:
When the program is compiled and loaded with green threads, the executable is
generated correctly. Here is a log of the compile/load:
gcc -g -I/usr/local/jdk1.2.2/include -I/usr/local/jdk1.2.2/include/linux -
L/usr/local/jdk1.2.2/jre/lib/i386/green_threads -
L/usr/local/jdk1.2.2/jre/lib/i386/classic -ljvm -lhpi -ldl invoke.c -o
invoke.out
invoke.c: In function `main':
invoke.c:34: warning: passing arg 2 of `JNI_CreateJavaVM' from incompatible
pointer type
When this green threads executable is executed, the call to JNI_CreateJavaVM
fails, and we get an infinite loop of diag/trace information as shown below:
SIGQUIT
Full thread dump Classic VM (1.2.2_006, green threads):
"SIGQUIT handler" (TID:0x40eb63e0, sys_thread_t:0x8101488, state:R) prio=5
"main" (TID:0x40eb61e0, sys_thread_t:0x804af78, state:R) prio=5
Monitor Cache Dump:
Registered Monitor Dump:
utf8 hash table: <unowned>
JNI pinning lock: <unowned>
JNI global reference lock: <unowned>
BinClass lock: <unowned>
Class linking lock: <unowned>
System class loader lock: <unowned>
Code rewrite lock: <unowned>
Heap lock: <unowned>
Monitor cache lock: owner "SIGQUIT handler" (0x8101488) 1 entry
Dynamic loading lock: <unowned>
Monitor IO lock: <unowned>
User signal monitor: <unowned>
Child death monitor: <unowned>
I/O monitor: <unowned>
Alarm monitor: <unowned>
Waiting to be notified:
<unknown thread> (0x80563e0)
Thread queue lock: owner "SIGQUIT handler" (0x8101488) 1 entry
Monitor registry: owner "SIGQUIT handler" (0x8101488) 1 entry
SIGQUIT
Full thread dump Classic VM (1.2.2_006, green threads):
"SIGQUIT handler" (TID:0x40eb63e0, sys_thread_t:0x8101488, state:R) prio=5
"main" (TID:0x40eb61e0, sys_thread_t:0x804af78, state:R) prio=5
Monitor Cache Dump:
Registered Monitor Dump:
utf8 hash table: <unowned>
JNI pinning lock: <unowned>
JNI global reference lock: <unowned>
BinClass lock: <unowned>
Class linking lock: <unowned>
System class loader lock: <unowned>
Code rewrite lock: <unowned>
Heap lock: <unowned>
Monitor cache lock: owner "SIGQUIT handler" (0x8101488) 1 entry
Dynamic loading lock: <unowned>
Monitor IO lock: <unowned>
User signal monitor: <unowned>
Child death monitor: <unowned>
I/O monitor: <unowned>
Alarm monitor: <unowned>
Waiting to be notified:
<unknown thread> (0x80563e0)
Thread queue lock: owner "SIGQUIT handler" (0x8101488) 1 entry
Monitor registry: owner "SIGQUIT handler" (0x8101488) 1 entry
SIGQUIT
When the program is compiled/loaded with native threads, the load fails because
of undefineds. A log of this compile/load follows:
gcc -g -I/usr/local/jdk1.2.2/include -I/usr/local/jdk1.2.2/include/linux -
L/usr/local/jdk1.2.2/jre/lib/i386/native_threads -
L/usr/local/jdk1.2.2/jre/lib/i386/classic -lhpi -ljvm -lpthread -ldl invoke.c -
o invoke.out
invoke.c: In function `main':
invoke.c:34: warning: passing arg 2 of `JNI_CreateJavaVM' from incompatible
pointer type
/usr/local/jdk1.2.2/jre/lib/i386/native_threads/libhpi.so: undefined reference
to `sem_destroy@@GLIBC_2.0'
/usr/local/jdk1.2.2/jre/lib/i386/native_threads/libhpi.so: undefined reference
to `sem_post@@GLIBC_2.0'
/usr/local/jdk1.2.2/jre/lib/i386/native_threads/libhpi.so: undefined reference
to `sem_wait@@GLIBC_2.0'
/usr/local/jdk1.2.2/jre/lib/i386/native_threads/libhpi.so: undefined reference
to `sem_init@@GLIBC_2.0'
collect2: ld returned 1 exit status
When the executable generated by compiling/loading against green threads is
executed with a LD_LIBRARY_PATH that causes the native libhpi.so to be loaded
at execution, the program executes correctly:
Hello World from C!
My application aborts in the following way:
SIGSEGV 11* segmentation violation
si_signo [11]: SIGSEGV 11* segmentation violation
si_errno [0]: Success
si_code [0]: SI_USER [pid: 0, uid: 0]
Full thread dump Classic VM (1.2.2_006, native threads):
"Finalizer" (TID:0x40eab320, sys_thread_t:0x8371538, state:CW, native
ID:0xc0c) prio=8
at java.lang.Object.wait(Native Method)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:108)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:123)
at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:170)
"Reference Handler" (TID:0x40eab3b0, sys_thread_t:0x836e230, state:CW,
natie ID:0x280b) prio=10
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Object.java:420)
at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:110)
"SIGQUIT handler" (TID:0x40eab3e0, sys_thread_t:0x836de00, state:R, native
D:0x240a) prio=5
"main" (TID:0x40eab1e0, sys_thread_t:0x82f0bf0, state:R, native ID:0x2009)
rio=5
at java.lang.Runtime.exitInternal(Native Method)
at java.lang.Runtime.exit(Runtime.java:79)
at java.lang.System.exit(System.java:655)
at Logger.<init>(Logger.java:21)
Monitor Cache Dump:
java.lang.ref.ReferenceQueue$Lock@40EAB338/40EE1028: <unowned>
Waiting to be notified:
"Finalizer" (0x8371538)
java.lang.ref.Reference$Lock@40EAB3C0/40EE0B20: <unowned>
Waiting to be notified:
"Reference Handler" (0x836e230)
Registered Monitor Dump:
utf8 hash table: <unowned>
JNI pinning lock: <unowned>
JNI global reference lock: <unowned>
BinClass lock: <unowned>
Class linking lock: <unowned>
System class loader lock: <unowned>
Code rewrite lock: <unowned>
Heap lock: <unowned>
Monitor cache lock: <unowned>
Thread queue lock: <unowned>
Monitor registry: <unowned>
The "invoke" application code is:
#include <jni.h>
#ifdef _WIN32
#define PATH_SEPARATOR ';'
#else /* UNIX */
#define PATH_SEPARATOR ':'
#endif
#define USER_CLASSPATH "." /* where Prog.class is */
main() {
JNIEnv *env;
JavaVM *jvm;
JDK1_1InitArgs vm_args;
jint res;
jclass cls;
jmethodID mid;
jstring jstr;
jobjectArray args;
char classpath[1024];
/* IMPORTANT: specify vm_args version # if you use JDK1.1.2 and beyond */
vm_args.version = 0x00010001;
JNI_GetDefaultJavaVMInitArgs(&vm_args);
/* Append USER_CLASSPATH to the end of default system class path */
sprintf(classpath, "%s%c%s",
vm_args.classpath, PATH_SEPARATOR, USER_CLASSPATH);
vm_args.classpath = classpath;
/* Create the Java VM */
res = JNI_CreateJavaVM(&jvm,&env,&vm_args);
if (res < 0) {
fprintf(stderr, "Can't create Java VM\n");
exit(1);
}
cls = (*env)->FindClass(env, "Prog");
if (cls == 0) {
fprintf(stderr, "Can't find Prog class\n");
exit(1);
}
mid = (*env)->GetStaticMethodID(env, cls, "main", "([Ljava/lang/String;)V");
if (mid == 0) {
fprintf(stderr, "Can't find Prog.main\n");
exit(1);
}
jstr = (*env)->NewStringUTF(env, " from C!");
if (jstr == 0) {
fprintf(stderr, "Out of memory\n");
exit(1);
}
args = (*env)->NewObjectArray(env, 1,
(*env)->FindClass(env, "java/lang/String"), jstr);
if (args == 0) {
fprintf(stderr, "Out of memory\n");
exit(1);
}
(*env)->CallStaticVoidMethod(env, cls, mid, args);
(*jvm)->DestroyJavaVM(jvm);
}
The java script invoked by the invoke.c code is named Prog.java and is:
public class Prog {
public static void main(String[] args) {
System.out.println("Hello World" + args[0]);
}
}
With Beta Refresh:
I downloaded the beta refresh last week and got essentially the same results.
With this version, the invoke executable linked with green threads executes
successfully when dynamically linked with the native threads shared
libraries, but it does not compile/load against the native shared libraries
because of the undefineds. (same as for other versions of the jdk I tried)
Here are relevant logs from using the 1.3 beta refresh version:
1. Log of compiling/loading the "invoke" test program:
gcc -g -I/usr/local/jdk1.3/include -I/usr/local/jdk1.3/include/linux -L/usr/
local/jdk1.3/jre/lib/i386/green_threads -L/usr/local/jdk1.3/jre/lib/i386/cla
ssic -ljvm -lhpi -ldl invoke.c -o invoke1.3.out
invoke.c: In function `main':
invoke.c:34: warning: passing arg 2 of `JNI_CreateJavaVM' from incompatible
pointer type
2. ldd output for the executable built by the above compile/load:
libjvm.so => /usr/local/jdk1.3/jre/lib/i386/classic/libjvm.so (0x40013000)
libhpi.so => /usr/local/jdk1.3/jre/lib/i386/green_threads/libhpi.so
(0x400a6000)
libdl.so.2 => /lib/libdl.so.2 (0x400c4000)
libc.so.6 => /lib/libc.so.6 (0x400c7000)
libm.so.6 => /lib/libm.so.6 (0x401ba000)
libnsl.so.1 => /lib/libnsl.so.1 (0x401d6000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
3. Log (small piece only; it loops forever) of executing the program:
SIGQUIT
Full thread dump Classic VM (1.3.0beta_refresh-b09, green threads):
"SIGQUIT handler" (TID:0x40ee3330, sys_thread_t:0x80bcee0, state:R)
prio=5
"main" (TID:0x40ee31a0, sys_thread_t:0x804af68, state:R) prio=5
Monitor Cache Dump:
Registered Monitor Dump:
utf8 hash table: <unowned>
JNI pinning lock: <unowned>
JNI global reference lock: <unowned>
BinClass lock: <unowned>
Class linking lock: <unowned>
System class loader lock: <unowned>
Code rewrite lock: <unowned>
Heap lock: <unowned>
Monitor cache lock: owner "SIGQUIT handler" (0x80bcee0) 1 entry
Dynamic loading lock: <unowned>
Monitor IO lock: <unowned>
User signal monitor: <unowned>
Child death monitor: <unowned>
I/O monitor: <unowned>
Alarm monitor: <unowned>
Waiting to be notified:
<unknown thread> (0x80563d0)
Thread queue lock: owner "SIGQUIT handler" (0x80bcee0) 1 entry
Monitor registry: owner "SIGQUIT handler" (0x80bcee0) 1 entry
SIGQUIT
Full thread dump Classic VM (1.3.0beta_refresh-b09, green threads):
"SIGQUIT handler" (TID:0x40ee3330, sys_thread_t:0x80bcee0, state:R)
prio=5
"main" (TID:0x40ee31a0, sys_thread_t:0x804af68, state:R) prio=5
Monitor Cache Dump:
Registered Monitor Dump:
utf8 hash table: <unowned>
JNI pinning lock: <unowned>
JNI global reference lock: <unowned>
BinClass lock: <unowned>
Class linking lock: <unowned>
System class loader lock: <unowned>
Code rewrite lock: <unowned>
Heap lock: <unowned>
Monitor cache lock: owner "SIGQUIT handler" (0x80bcee0) 1 entry
Dynamic loading lock: <unowned>
Monitor IO lock: <unowned>
User signal monitor: <unowned>
Child death monitor: <unowned>
I/O monitor: <unowned>
Alarm monitor: <unowned>
Waiting to be notified:
<unknown thread> (0x80563d0)
Thread queue lock: owner "SIGQUIT handler" (0x80bcee0) 1 entry
Monitor registry: owner "SIGQUIT handler" (0x80bcee0) 1 entry
SIGQUIT
(Review ID: 107220)
======================================================================