< prev index next >
test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
Print this page
rev 49498 : [mq]: StackGuardPages_0
@@ -31,10 +31,11 @@
* It's OK - don't file a bug.
*/
#include <assert.h>
#include <jni.h>
+#include <jvm.h>
#include <alloca.h>
#include <signal.h>
#include <string.h>
#include <sys/mman.h>
#include <stdlib.h>
@@ -89,10 +90,24 @@
fprintf(stderr, "Test ERROR. Can't set sigaction (%d)\n", errno);
exit(7);
}
}
+int get_java_stacksize () {
+ size_t stacksize;
+ pthread_attr_t attr;
+ JDK1_1InitArgs jdk_args;
+
+ jdk_args.version = JNI_VERSION_1_1;
+ JNI_GetDefaultJavaVMInitArgs(&jdk_args);
+ if (jdk_args.javaStackSize <= 0) {
+ fprintf(stderr, "Test ERROR. Can't get a valid value for the default stacksize.\n");
+ exit(7);
+ }
+ return jdk_args.javaStackSize;
+}
+
void *run_java_overflow (void *p) {
JNIEnv *env;
jclass class_id;
jmethodID method_id;
int res;
@@ -252,17 +267,23 @@
if (JNI_CreateJavaVM (&_jvm, (void **)&env, &vm_args) < 0 ) {
fprintf(stderr, "Test ERROR. Can't create JavaVM\n");
exit(7);
}
+ int stack_size = get_java_stacksize();
pthread_t thr;
+ pthread_attr_t thread_attr;
+
+ pthread_attr_init(&thread_attr);
+ pthread_attr_setstacksize(&thread_attr, stack_size);
if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) {
printf("\nTesting JAVA_OVERFLOW\n");
printf("Testing stack guard page behaviour for other thread\n");
- pthread_create (&thr, NULL, run_java_overflow, NULL);
+
+ pthread_create (&thr, &thread_attr, run_java_overflow, NULL);
pthread_join (thr, NULL);
printf("Testing stack guard page behaviour for initial thread\n");
run_java_overflow(NULL);
// This test crash on error
@@ -271,11 +292,11 @@
if (argc > 1 && strcmp(argv[1], "test_native_overflow") == 0) {
printf("\nTesting NATIVE_OVERFLOW\n");
printf("Testing stack guard page behaviour for other thread\n");
- pthread_create (&thr, NULL, run_native_overflow, NULL);
+ pthread_create (&thr, &thread_attr, run_native_overflow, NULL);
pthread_join (thr, NULL);
printf("Testing stack guard page behaviour for initial thread\n");
run_native_overflow(NULL);
< prev index next >