summaryrefslogtreecommitdiff
path: root/openjdk8-aarch64-port-snapshot/hotspot/test/runtime/7107135
diff options
context:
space:
mode:
Diffstat (limited to 'openjdk8-aarch64-port-snapshot/hotspot/test/runtime/7107135')
-rw-r--r--openjdk8-aarch64-port-snapshot/hotspot/test/runtime/7107135/Test.java65
-rw-r--r--openjdk8-aarch64-port-snapshot/hotspot/test/runtime/7107135/Test7107135.sh91
-rw-r--r--openjdk8-aarch64-port-snapshot/hotspot/test/runtime/7107135/TestMT.java85
-rw-r--r--openjdk8-aarch64-port-snapshot/hotspot/test/runtime/7107135/test.c39
4 files changed, 280 insertions, 0 deletions
diff --git a/openjdk8-aarch64-port-snapshot/hotspot/test/runtime/7107135/Test.java b/openjdk8-aarch64-port-snapshot/hotspot/test/runtime/7107135/Test.java
new file mode 100644
index 00000000..84f3ab33
--- /dev/null
+++ b/openjdk8-aarch64-port-snapshot/hotspot/test/runtime/7107135/Test.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2002-2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011 SAP AG. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+class Test {
+
+ static boolean loadLib(String libName){
+ try {
+ System.loadLibrary(libName);
+ System.out.println("Loaded library "+ libName + ".");
+ return true;
+ } catch (SecurityException e) {
+ System.out.println("loadLibrary(\"" + libName + "\") throws: " + e + "\n");
+ } catch (UnsatisfiedLinkError e) {
+ System.out.println("loadLibrary(\"" + libName + "\") throws: " + e + "\n");
+ }
+ return false;
+ }
+
+ public static int counter = 1;
+
+ static int Runner() {
+ counter = counter * -1;
+ int i = counter;
+ if(counter < 2) counter += Runner();
+ return i;
+ }
+
+ public static int run() {
+ try{
+ Runner();
+ } catch (StackOverflowError e) {
+ System.out.println("Caught stack overflow error.");
+ return 0;
+ } catch (OutOfMemoryError e) {
+ return 0;
+ }
+ return 2;
+ }
+
+ public static void main(String argv[]) {
+ loadLib(argv[0]);
+ System.exit(run());
+ }
+}
diff --git a/openjdk8-aarch64-port-snapshot/hotspot/test/runtime/7107135/Test7107135.sh b/openjdk8-aarch64-port-snapshot/hotspot/test/runtime/7107135/Test7107135.sh
new file mode 100644
index 00000000..c2834564
--- /dev/null
+++ b/openjdk8-aarch64-port-snapshot/hotspot/test/runtime/7107135/Test7107135.sh
@@ -0,0 +1,91 @@
+#!/bin/sh
+
+#
+# Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011 SAP AG. All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+##
+## @test Test7107135.sh
+## @bug 7107135
+## @summary Stack guard pages lost after loading library with executable stack.
+## @run shell Test7107135.sh
+##
+
+if [ "${TESTSRC}" = "" ]
+then
+ TESTSRC=${PWD}
+ echo "TESTSRC not set. Using "${TESTSRC}" as default"
+fi
+echo "TESTSRC=${TESTSRC}"
+## Adding common setup Variables for running shell tests.
+. ${TESTSRC}/../../test_env.sh
+
+# set platform-dependent variables
+OS=`uname -s`
+case "$OS" in
+ Linux)
+ echo "Testing on Linux"
+ ;;
+ *)
+ NULL=NUL
+ PS=";"
+ FS="\\"
+ echo "Test passed; only valid for Linux"
+ exit 0;
+ ;;
+esac
+
+ARCH=`uname -m`
+
+THIS_DIR=.
+
+cp ${TESTSRC}${FS}*.java ${THIS_DIR}
+${TESTJAVA}${FS}bin${FS}javac *.java
+
+gcc -fPIC -shared -c -o test.o -I${TESTJAVA}${FS}include -I${TESTJAVA}${FS}include${FS}linux ${TESTSRC}${FS}test.c
+ld -shared -z execstack -o libtest-rwx.so test.o
+ld -shared -z noexecstack -o libtest-rw.so test.o
+
+
+LD_LIBRARY_PATH=${THIS_DIR}
+echo LD_LIBRARY_PATH = ${LD_LIBRARY_PATH}
+export LD_LIBRARY_PATH
+
+# This should not fail.
+echo Check testprogram. Expected to pass:
+echo ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} Test test-rw
+${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} Test test-rw
+
+echo
+echo Test changing of stack protection:
+echo ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} Test test-rw
+${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} Test test-rwx
+
+if [ "$?" == "0" ]
+then
+ echo
+ echo ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} TestMT test-rwx
+ ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} TestMT test-rwx
+fi
+
+exit $?
diff --git a/openjdk8-aarch64-port-snapshot/hotspot/test/runtime/7107135/TestMT.java b/openjdk8-aarch64-port-snapshot/hotspot/test/runtime/7107135/TestMT.java
new file mode 100644
index 00000000..edea698a
--- /dev/null
+++ b/openjdk8-aarch64-port-snapshot/hotspot/test/runtime/7107135/TestMT.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2002-2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011 SAP AG. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+class TestMT {
+
+ static boolean loadLib(String libName) {
+ try {
+ System.loadLibrary(libName);
+ System.out.println("Loaded library "+ libName + ".");
+ return true;
+ } catch (SecurityException e) {
+ System.out.println("loadLibrary(\"" + libName + "\") throws: " + e + "\n");
+ } catch (UnsatisfiedLinkError e) {
+ System.out.println("loadLibrary(\"" + libName + "\") throws: " + e + "\n");
+ }
+ return false;
+ }
+
+ public static int counter = 1;
+ static int Runner() {
+ counter = counter * -1;
+ int i = counter;
+ if (counter < 2) counter += Runner();
+ return i;
+ }
+
+ public static int run(String msg) {
+ try {
+ Runner();
+ } catch (StackOverflowError e) {
+ System.out.println(msg + " caught stack overflow error.");
+ return 0;
+ } catch (OutOfMemoryError e) {
+ return 0;
+ }
+ return 2;
+ }
+
+ public static void main(String argv[]) {
+ try {
+ for (int i = 0; i < 20; i++) {
+ Thread t = new DoStackOverflow("SpawnedThread " + i);
+ t.start();
+ }
+ run("Main thread");
+ loadLib("test-rwx");
+ run("Main thread");
+ } catch (Exception e) {
+ System.out.println(e);
+ }
+ }
+
+ static class DoStackOverflow extends Thread {
+ public DoStackOverflow(String name) {
+ super(name);
+ }
+ public void run() {
+ for (int i = 0; i < 10; ++i) {
+ TestMT.run(getName());
+ yield();
+ }
+ }
+ }
+}
diff --git a/openjdk8-aarch64-port-snapshot/hotspot/test/runtime/7107135/test.c b/openjdk8-aarch64-port-snapshot/hotspot/test/runtime/7107135/test.c
new file mode 100644
index 00000000..602063f6
--- /dev/null
+++ b/openjdk8-aarch64-port-snapshot/hotspot/test/runtime/7107135/test.c
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2002-2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011 SAP AG. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include "jni.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+JNIEXPORT jint JNICALL Java_Test_someMethod(JNIEnv *env, jobject mainObject) {
+ return 3;
+}
+
+#ifdef __cplusplus
+}
+#endif