This is happening on linux 2.6.18-238.5.1.el5 with a 64 bit app. My process stack size is 10MB. However, after a (successful) call to JNI_CreateJavaVM I only seem to have 1-2 MB left on the stack. If I got past it - I get memory fault as if I'm overflowing the stack.
A few notes:
- If I DON'T create a JVM then I get have access to the whole my my 10MB stack.
- The same test program with the same makefile runs fine on Solaris even with a call to JVM
Test source:
#include <jni.h>
#include <stdio.h>
#include <stdlib.h>
void CreateVM(JavaVM ** jvm) {
JNIEnv *env;
JavaVMInitArgs vm_args;
JavaVMOption options[1];
options[0].optionString = (char*)"-Xcheck:jni";
vm_args.version = JNI_VERSION_1_6;
vm_args.nOptions = 0;
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");
exit(1);
}
if ( env->ExceptionCheck() == JNI_TRUE ) {
printf("exception\n");
exit(1);
}
}
void f() {
printf("inside...\n");
//eat up a few megs of stack
char stackTest[0x2FFFFF];
printf("...returning");
}
int main(int argc, char* argv[]) {
JavaVM * jvm;
CreateVM(&jvm);
f();
printf("exiting...\n");
return 0;
}
Build command:
g++ -m64 CTest.cpp -I/import/bitbucket/JDK/jdk1.6.0_26/include -I/import/bitbucket/JDK/jdk1.6.0_26/include/linux -L/import/bitbucket/JDK/jdk1.6.0_26/jre/lib/amd64 -L/import/bitbucket/JDK/jdk1.6.0_26/jre/lib/amd64/server -ljava -ljvm
strace -f a.out
and post results in the internet? – osgx