author | gthornbr |
Fri, 15 Jul 2016 10:46:08 -0700 | |
changeset 39974 | f76ca6458acb |
child 40330 | da68db6130b8 |
permissions | -rw-r--r-- |
39974
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
1 |
/* |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
2 |
* Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
4 |
* |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
8 |
* |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
13 |
* accompanied this code). |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
14 |
* |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
18 |
* |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
21 |
* questions. |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
22 |
* |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
23 |
*/ |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
24 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
25 |
/* This code tests the fact that we actually remove stack guard page when calling |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
26 |
* JavaThread::exit() i.e. when detaching from current thread. |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
27 |
* We overflow the stack and check that we get access error because of a guard page. |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
28 |
* Than we detach from vm thread and overflow stack once again. This time we shouldn't |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
29 |
* get access error because stack guard page is removed |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
30 |
* |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
31 |
* Notice: due a complicated interaction of signal handlers, the test may crash. |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
32 |
* It's OK - don't file a bug. |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
33 |
*/ |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
34 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
35 |
#include <assert.h> |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
36 |
#include <jni.h> |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
37 |
#include <alloca.h> |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
38 |
#include <signal.h> |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
39 |
#include <string.h> |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
40 |
#include <sys/mman.h> |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
41 |
#include <stdlib.h> |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
42 |
#include <sys/ucontext.h> |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
43 |
#include <setjmp.h> |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
44 |
#include <unistd.h> |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
45 |
#include <sys/syscall.h> |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
46 |
#include <errno.h> |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
47 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
48 |
#include <pthread.h> |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
49 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
50 |
#define CLASS_PATH_OPT "-Djava.class.path=" |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
51 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
52 |
JavaVM* _jvm; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
53 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
54 |
static jmp_buf context; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
55 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
56 |
static int _last_si_code = -1; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
57 |
static int _failures = 0; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
58 |
static int _rec_count = 0; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
59 |
static int _kp_rec_count = 0; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
60 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
61 |
pid_t gettid() { |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
62 |
return (pid_t) syscall(SYS_gettid); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
63 |
} |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
64 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
65 |
static void handler(int sig, siginfo_t *si, void *unused) { |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
66 |
_last_si_code = si->si_code; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
67 |
printf("Got SIGSEGV(%d) at address: 0x%lx\n",si->si_code, (long) si->si_addr); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
68 |
longjmp(context, 1); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
69 |
} |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
70 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
71 |
void set_signal_handler() { |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
72 |
static char altstack[SIGSTKSZ]; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
73 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
74 |
stack_t ss = { |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
75 |
.ss_size = SIGSTKSZ, |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
76 |
.ss_flags = 0, |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
77 |
.ss_sp = altstack |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
78 |
}; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
79 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
80 |
struct sigaction sa = { |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
81 |
.sa_sigaction = handler, |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
82 |
.sa_flags = SA_ONSTACK | SA_SIGINFO | SA_RESETHAND |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
83 |
}; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
84 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
85 |
_last_si_code = -1; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
86 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
87 |
sigaltstack(&ss, 0); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
88 |
sigemptyset(&sa.sa_mask); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
89 |
if (sigaction(SIGSEGV, &sa, NULL) == -1) { |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
90 |
fprintf(stderr, "Test ERROR. Can't set sigaction (%d)\n", errno); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
91 |
exit(7); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
92 |
} |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
93 |
} |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
94 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
95 |
void *run_java_overflow (void *p) { |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
96 |
JNIEnv *env; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
97 |
jclass class_id; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
98 |
jmethodID method_id; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
99 |
int res; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
100 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
101 |
res = (*_jvm)->AttachCurrentThread(_jvm, (void**)&env, NULL); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
102 |
if (res != JNI_OK) { |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
103 |
fprintf(stderr, "Test ERROR. Can't attach to current thread\n"); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
104 |
exit(7); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
105 |
} |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
106 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
107 |
class_id = (*env)->FindClass (env, "DoOverflow"); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
108 |
if (class_id == NULL) { |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
109 |
fprintf(stderr, "Test ERROR. Can't load class DoOverflow\n"); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
110 |
exit(7); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
111 |
} |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
112 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
113 |
method_id = (*env)->GetStaticMethodID(env, class_id, "printIt", "()V"); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
114 |
if (method_id == NULL) { |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
115 |
fprintf(stderr, "Test ERROR. Can't find method DoOverflow.printIt\n"); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
116 |
exit(7); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
117 |
} |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
118 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
119 |
(*env)->CallStaticVoidMethod(env, class_id, method_id, NULL); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
120 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
121 |
res = (*_jvm)->DetachCurrentThread(_jvm); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
122 |
if (res != JNI_OK) { |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
123 |
fprintf(stderr, "Test ERROR. Can't call detach from current thread\n"); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
124 |
exit(7); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
125 |
} |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
126 |
return NULL; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
127 |
} |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
128 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
129 |
void do_overflow(){ |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
130 |
int *p = alloca(sizeof(int)); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
131 |
if (_kp_rec_count == 0 || _rec_count < _kp_rec_count) { |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
132 |
_rec_count ++; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
133 |
do_overflow(); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
134 |
} |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
135 |
} |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
136 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
137 |
void *run_native_overflow(void *p) { |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
138 |
// Test that stack guard page is correctly set for initial and non initial thread |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
139 |
// and correctly removed for the initial thread |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
140 |
JNIEnv *env; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
141 |
jclass class_id; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
142 |
jmethodID method_id; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
143 |
int res; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
144 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
145 |
printf("run_native_overflow %ld\n", (long) gettid()); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
146 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
147 |
res = (*_jvm)->AttachCurrentThread(_jvm, (void **)&env, NULL); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
148 |
if (res != JNI_OK) { |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
149 |
fprintf(stderr, "Test ERROR. Can't attach to current thread\n"); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
150 |
exit(7); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
151 |
} |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
152 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
153 |
class_id = (*env)->FindClass (env, "DoOverflow"); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
154 |
if (class_id == NULL) { |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
155 |
fprintf(stderr, "Test ERROR. Can't load class DoOverflow\n"); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
156 |
exit(7); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
157 |
} |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
158 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
159 |
method_id = (*env)->GetStaticMethodID (env, class_id, "printAlive", "()V"); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
160 |
if (method_id == NULL) { |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
161 |
fprintf(stderr, "Test ERROR. Can't find method DoOverflow.printAlive\n"); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
162 |
exit(7); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
163 |
} |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
164 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
165 |
(*env)->CallStaticVoidMethod (env, class_id, method_id, NULL); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
166 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
167 |
set_signal_handler(); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
168 |
if (! setjmp(context)) { |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
169 |
do_overflow(); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
170 |
} |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
171 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
172 |
if (_last_si_code == SEGV_ACCERR) { |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
173 |
printf("Test PASSED. Got access violation accessing guard page at %d\n", _rec_count); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
174 |
} |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
175 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
176 |
res = (*_jvm)->DetachCurrentThread(_jvm); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
177 |
if (res != JNI_OK) { |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
178 |
fprintf(stderr, "Test ERROR. Can't call detach from current thread\n"); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
179 |
exit(7); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
180 |
} |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
181 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
182 |
if (getpid() != gettid()) { |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
183 |
// For non-initial thread we don't unmap the region but call os::uncommit_memory and keep PROT_NONE |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
184 |
// so if host has enough swap space we will get the same SEGV with code SEGV_ACCERR(2) trying |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
185 |
// to access it as if the guard page is present. |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
186 |
// We have no way to check this, so bail out, marking test as succeeded |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
187 |
printf("Test PASSED. Not initial thread\n"); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
188 |
return NULL; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
189 |
} |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
190 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
191 |
// Limit depth of recursion for second run. It can't exceed one for first run. |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
192 |
_kp_rec_count = _rec_count; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
193 |
_rec_count = 0; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
194 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
195 |
set_signal_handler(); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
196 |
if (! setjmp(context)) { |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
197 |
do_overflow(); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
198 |
} |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
199 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
200 |
if (_last_si_code == SEGV_ACCERR) { |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
201 |
++ _failures; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
202 |
fprintf(stderr,"Test FAILED. Stack guard page is still there at %d\n", _rec_count); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
203 |
} else if (_last_si_code == -1) { |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
204 |
printf("Test PASSED. No stack guard page is present. Maximum recursion level reached at %d\n", _rec_count); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
205 |
} |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
206 |
else{ |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
207 |
printf("Test PASSED. No stack guard page is present. SIGSEGV(%d) at %d\n", _last_si_code, _rec_count); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
208 |
} |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
209 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
210 |
return NULL; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
211 |
} |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
212 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
213 |
void usage() { |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
214 |
fprintf(stderr, "Usage: invoke test_java_overflow\n"); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
215 |
fprintf(stderr, " invoke test_native_overflow\n"); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
216 |
} |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
217 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
218 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
219 |
int main (int argc, const char** argv) { |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
220 |
JavaVMInitArgs vm_args; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
221 |
JavaVMOption options[3]; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
222 |
JNIEnv* env; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
223 |
int optlen; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
224 |
char *javaclasspath = NULL; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
225 |
char javaclasspathopt[4096]; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
226 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
227 |
printf("Test started with pid: %ld\n", (long) getpid()); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
228 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
229 |
/* set the java class path so the DoOverflow class can be found */ |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
230 |
javaclasspath = getenv("CLASSPATH"); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
231 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
232 |
if (javaclasspath == NULL) { |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
233 |
fprintf(stderr, "Test ERROR. CLASSPATH is not set\n"); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
234 |
exit(7); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
235 |
} |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
236 |
optlen = strlen(CLASS_PATH_OPT) + strlen(javaclasspath) + 1; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
237 |
if (optlen > 4096) { |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
238 |
fprintf(stderr, "Test ERROR. CLASSPATH is too long\n"); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
239 |
exit(7); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
240 |
} |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
241 |
snprintf(javaclasspathopt, sizeof(javaclasspathopt), "%s%s", |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
242 |
CLASS_PATH_OPT, javaclasspath); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
243 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
244 |
options[0].optionString = "-Xint"; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
245 |
options[1].optionString = "-Xss328k"; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
246 |
options[2].optionString = javaclasspathopt; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
247 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
248 |
vm_args.version = JNI_VERSION_1_2; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
249 |
vm_args.ignoreUnrecognized = JNI_TRUE; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
250 |
vm_args.options = options; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
251 |
vm_args.nOptions = 3; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
252 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
253 |
if (JNI_CreateJavaVM (&_jvm, (void **)&env, &vm_args) < 0 ) { |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
254 |
fprintf(stderr, "Test ERROR. Can't create JavaVM\n"); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
255 |
exit(7); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
256 |
} |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
257 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
258 |
pthread_t thr; |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
259 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
260 |
if (argc > 1 && strcmp(argv[1], "test_java_overflow") == 0) { |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
261 |
printf("\nTesting JAVA_OVERFLOW\n"); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
262 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
263 |
printf("Testing stack guard page behaviour for other thread\n"); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
264 |
pthread_create (&thr, NULL, run_java_overflow, NULL); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
265 |
pthread_join (thr, NULL); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
266 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
267 |
printf("Testing stack guard page behaviour for initial thread\n"); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
268 |
run_java_overflow(NULL); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
269 |
// This test crash on error |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
270 |
exit(0); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
271 |
} |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
272 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
273 |
if (argc > 1 && strcmp(argv[1], "test_native_overflow") == 0) { |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
274 |
printf("\nTesting NATIVE_OVERFLOW\n"); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
275 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
276 |
printf("Testing stack guard page behaviour for other thread\n"); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
277 |
pthread_create (&thr, NULL, run_native_overflow, NULL); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
278 |
pthread_join (thr, NULL); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
279 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
280 |
printf("Testing stack guard page behaviour for initial thread\n"); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
281 |
run_native_overflow(NULL); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
282 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
283 |
exit((_failures > 0) ? 1 : 0); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
284 |
} |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
285 |
|
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
286 |
fprintf(stderr, "Test ERROR. Unknown parameter %s\n", ((argc > 1) ? argv[1] : "none")); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
287 |
usage(); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
288 |
exit(7); |
f76ca6458acb
8144278: [TESTBUG] hotspot/runtime/StackGuardPages/testme.sh should use native library build support
gthornbr
parents:
diff
changeset
|
289 |
} |