aspose file tools*
The moose likes Java in General and the fly likes JNI_CreateJavaVM gives core dump on linux Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "JNI_CreateJavaVM gives core dump on linux" Watch "JNI_CreateJavaVM gives core dump on linux" New topic
Author

JNI_CreateJavaVM gives core dump on linux

Deepak Bhatt
Greenhorn

Joined: May 22, 2001
Posts: 2
All
My C program on linux (Red Hat 7) calls CreateJavaVM and I get the following error message.
Segmentation fault (core dumped)
I am using JDK1.3 from SUN.
Here is the C program
*****************************************************
#include <jni.h>
#include <stdio.h>
JavaVM *jvm; /* Pointer to a Java VM */
JNIEnv *env; /* Pointer to native method interface */
JavaVMInitArgs vm_args; /* JDK 1.1 VM initialization requirements */
JavaVMOption options[1];
main(int argc, char **argv ) {
jclass cls;
jmethodID mid;
jthrowable jthr;
int retval;
int result = 0;
long temp12[10];
/* Setup the environment */
options[0].optionString = "-Djava.class.path=/usr/java/jdk1.3.0_02/lib/r
t.jar:.";
vm_args.version = 0x00010002;
vm_args.options = options;
vm_args.nOptions = 1;
/* Instantiate JVM */
printf("Calling create Java VM");
fflush(stdout);
JNI_CreateJavaVM(&jvm, (void**)&env, (void*)&vm_args );
printf("Java VM Created");
fflush(stdout);
/* Find the class we want to load */
cls = (*env)->FindClass( env, "Hello" );
/* Find the method we want to use */
mid = (*env)->GetStaticMethodID(env, cls, "main", "([Ljava/lang/String
V");
/* Call the method we want to use */
(*env)->CallStaticVoidMethod(env, cls, mid);
}
**************************************************************
Following command I am using for compilaition
gcc -I/usr/java/jdk1.3.0_02/include -I/usr/java/jdk1.3.0_02/include/linux -L/usr/java/jdk1.3.0_02/jre/lib/i386 -L/usr/java/jdk1.3.0_02/jre/lib/i386/classic -L/usr/java/jdk1.3.0_02/jre/lib/i386/green_threads -ljvm -lhpi C2JavaVM.c
**************************************************************
Following is the gdb dump for the core
****************************************************************
GNU gdb 5.0
Copyright 2000 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux"...
Core was generated by `./a.out'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /usr/java/jdk1.3.0_02/jre/lib/i386/classic/libjvm.so...
done.
Loaded symbols for /usr/java/jdk1.3.0_02/jre/lib/i386/classic/libjvm.so
Reading symbols from /usr/java/jdk1.3.0_02/jre/lib/i386/green_threads/libhpi.so.
..done.
Loaded symbols for /usr/java/jdk1.3.0_02/jre/lib/i386/green_threads/libhpi.so
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/libm.so.6...done.
Loaded symbols for /lib/libm.so.6
Reading symbols from /lib/libnsl.so.1...done.
Loaded symbols for /lib/libnsl.so.1
Reading symbols from /lib/libdl.so.2...done.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /usr/java/jdk1.3.0_02/jre/lib/i386/native_threads/libhpi.so
...done.
Loaded symbols for /usr/java/jdk1.3.0_02/jre/lib/i386/native_threads/libhpi.so
Reading symbols from /lib/libpthread.so.0...done.
rw_common (): write: Success.
warning: unable to set global thread event mask
[New Thread 1024 (LWP 16704)]
rw_common (): write: Success.
warning: stop_or_attach_thread: generic error
Loaded symbols for /lib/libpthread.so.0
#0 _dl_lookup_symbol_skip (undef_name=0x400be534 "_filbuf",
undef_map=0x40016c50, ref=0xbffff63c, symbol_scope=0x40016db0,
skip_map=0x40017420) at dl-lookup.c:311
311 dl-lookup.c: No such file or directory.
(gdb) bt
#0 _dl_lookup_symbol_skip (undef_name=0x400be534 "_filbuf",
undef_map=0x40016c50, ref=0xbffff63c, symbol_scope=0x40016db0,
skip_map=0x40017420) at dl-lookup.c:311
#1 0x401d8876 in _dl_sym (handle=0xffffffff, name=0x400be534 "_filbuf",
who=0x40016db4) at dl-sym.c:72
#2 0x40229470 in dlsym_doit (a=0xbffff784) at dlsym.c:39
#3 0x4000db7c in _dl_catch_error (objname=0x4022af8c, errstring=0x4022af90,
operate=0x40229450 <dlsym_doit>, args=0xbffff784) at dl-error.c:138
#4 0x4022971b in _dlerror_run (operate=0x40229450 <dlsym_doit>,
args=0xbffff784) at dlerror.c:132
#5 0x40229436 in dlsym (handle=0xffffffff, name=0x400be534 "_filbuf")
at dlsym.c:51
#6 0x400b2b9d in initializeWrappers ()
from /usr/java/jdk1.3.0_02/jre/lib/i386/green_threads/libhpi.so
#7 0x400b2bc9 in InitializeAsyncIO ()
from /usr/java/jdk1.3.0_02/jre/lib/i386/green_threads/libhpi.so
#8 0x400bdc36 in sysThreadBootstrap ()
from /usr/java/jdk1.3.0_02/jre/lib/i386/green_threads/libhpi.so
#9 0x4008f485 in InitializeJavaVM ()
from /usr/java/jdk1.3.0_02/jre/lib/i386/classic/libjvm.so
#10 0x4006561a in JNI_CreateJavaVM ()
from /usr/java/jdk1.3.0_02/jre/lib/i386/classic/libjvm.so
#11 0x8048699 in main ()
**************************************************************
The program works fine on Solaris 2.8, So I think there is something wrong in the way I am compiline my program on linux.
Please let me know if you have any clue to this..
regards
-Deepak
Deepak Bhatt
Greenhorn

Joined: May 22, 2001
Posts: 2
Problem was using the wrong library..instead of green_threads I need to use native_threads along with the pthread library..
I think we can close this issue now..
regards
-deepak
 
 
subject: JNI_CreateJavaVM gives core dump on linux
 
Similar Threads
GetStringUTFChars
WebLogic 9.2 MP3 goes down with java.lang.StackOverflowError on Oracle Enterprise Linux 4
HotSpot Virtual Machine Error : 11
Undefined reference in JNI
Undefined reference in JNI