I am trying to use the JNI invocation interface from within some C code which in turn is invoked from Perl (Perl -> C -> Java).
The problem is, when the Perl process ends, i end up this:
*** glibc detected *** /usr/bin/perl: munmap_chunk(): invalid pointer: 0xb68d3880 ***
======= Backtrace: =========
/lib/i686/cmov/libc.so.6(+0x6b321)[0xb7e20321]
/lib/i686/cmov/libc.so.6(+0x6c59e)[0xb7e2159e]
/usr/bin/perl(perl_destruct+0x1290)[0x807dd30]
/usr/bin/perl(main+0x95)[0x80642a5]
/lib/i686/cmov/libc.so.6(__libc_start_main+0xe6)[0xb7dcbc76]
/usr/bin/perl[0x8064171]
I am simply invoking this function once, which creates the JVM and later invokes DestroyJavaVM...
static void test( void ) {
JavaVM *jvm;
JNIEnv *env;
JavaVMInitArgs vm_args;
JavaVMOption options[ 1 ];
options[ 0 ].optionString = "-Djava.class.path=/tmp";
vm_args.version = JNI_VERSION_1_6;
vm_args.nOptions = 1;
vm_args.options = options;
vm_args.ignoreUnrecognized = 0;
int ret = JNI_CreateJavaVM( &jvm, ( void** ) &env, &vm_args );
if(ret < 0)
printf("\nUnable to Launch JVM\n");
else {
if( (*env)->ExceptionOccurred( env ) )
(*env)->ExceptionDescribe( env );
(*jvm)->DestroyJavaVM( jvm );
}
}
Can anyone offer me any clues as to what may be happening here? I am guessing that DestroyJavaVM is not freeing the resources allocated by the JVM and this interferes with garbage collection in Perl...