При компиляции и запуске следующего кода в valgrind я постоянно получаю ошибки "Invalid write of size 4". Есть ли чистый способ вызова JNI_CreateJavaVM (), чтобы valgrind не выбрасывал?
#include <jni.h>
#include <stdlib.h>
#include <string.h>
int main()
{
JavaVMInitArgs * vm_args = calloc(1, sizeof(JavaVMInitArgs));
JavaVM * jvm = NULL;
JNIEnv * env = NULL;
vm_args->version = JNI_VERSION_1_6;
vm_args->nOptions = 0;
vm_args->options = NULL;
JNI_CreateJavaVM(&jvm, (void **)&env, vm_args);
return 0;
}
Вот команда valgrind, которую я выполняю:
valgrind --tool=memcheck --leak-check=yes --num-callers=20 --smc-check=all ./test
Одна запись из моего лога в Вулгринде:
==9004== Invalid write of size 4
==9004== at 0x4D5A3C8: ???
==9004== by 0x4D512CB: ???
==9004== by 0x423374F: JavaCalls::call_helper(JavaValue*, methodHandle*, JavaCallArguments*, Thread*) (in /usr/java/jdk1.6.0_21/jre/lib/i386/client/libjvm.so)
==9004== by 0x4361B67: os::os_exception_wrapper(void (*)(JavaValue*, methodHandle*, JavaCallArguments*, Thread*), JavaValue*, methodHandle*, JavaCallArguments*, Thread*) (in /usr/java/jdk1.6.0_21/jre/lib/i386/client/libjvm.so)
==9004== by 0x42335AE: JavaCalls::call(JavaValue*, methodHandle, JavaCallArguments*, Thread*) (in /usr/java/jdk1.6.0_21/jre/lib/i386/client/libjvm.so)
==9004== by 0x420F8C5: instanceKlass::call_class_initializer_impl(instanceKlassHandle, Thread*) (in /usr/java/jdk1.6.0_21/jre/lib/i386/client/libjvm.so)
==9004== by 0x420E650: instanceKlass::initialize_impl(instanceKlassHandle, Thread*) (in /usr/java/jdk1.6.0_21/jre/lib/i386/client/libjvm.so)
==9004== by 0x420DB97: instanceKlass::initialize(Thread*) (in /usr/java/jdk1.6.0_21/jre/lib/i386/client/libjvm.so)
==9004== by 0x420E8AB: instanceKlass::initialize_impl(instanceKlassHandle, Thread*) (in /usr/java/jdk1.6.0_21/jre/lib/i386/client/libjvm.so)
==9004== by 0x420DB97: instanceKlass::initialize(Thread*) (in /usr/java/jdk1.6.0_21/jre/lib/i386/client/libjvm.so)
==9004== by 0x440D660: Threads::create_vm(JavaVMInitArgs*, bool*) (in /usr/java/jdk1.6.0_21/jre/lib/i386/client/libjvm.so)
==9004== by 0x4265395: JNI_CreateJavaVM (in /usr/java/jdk1.6.0_21/jre/lib/i386/client/libjvm.so)
==9004== by 0x804845F: main (jvm.c:15)
==9004== Address 0xbeb54078 is not stack'd, malloc'd or (recently) free'd
Спасибо,
Chenz