Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack009.java
41159 views
/*1* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @key stress26*27* @summary converted from VM testbase nsk/stress/stack/stack009.28* VM testbase keywords: [stress, quick, stack, nonconcurrent]29* VM testbase readme:30* DESCRIPTION31* The test provokes second stack overflow from within the32* stack overflow handler.33* This test measures a number of recursive invocations until34* StackOverflowError, and then tries to make an invocation35* for the fixed invocations depth from within the "catch"36* block just caught the 1st stack overflow. The depth of new37* invocations is 10 times that depth seen at the 1st stack38* overflow; so that another stack overflow occurs.39* The test is deemed passed, if VM have not crashed, and40* if there is no exception thrown other than due to stack41* overflow.42* COMMENTS43* This test crashes HS versions 2.0, 1.3, and 1.4 on Win3244* and Solaris platforms.45* See the bug:46* 4366625 (P4/S4) multiple stack overflow causes HS crash47*48* @requires vm.opt.DeoptimizeALot != true49* @run main/othervm/timeout=900 nsk.stress.stack.stack00950*/5152package nsk.stress.stack;535455import java.io.PrintStream;5657public class stack009 {58public static void main(String[] args) {59int exitCode = run(args, System.out);60System.exit(exitCode + 95);61}6263public static int run(String args[], PrintStream out) {64for (int depth = 100; ; depth += 100)65try {66recurse(depth);67} catch (Error error1) {68if (!(error1 instanceof StackOverflowError) &&69!(error1 instanceof OutOfMemoryError))70throw error1;7172out.println("Max. depth: " + depth);7374try {75recurse(10 * depth);76out.println("?");77} catch (Error error2) {78if (!(error2 instanceof StackOverflowError) &&79!(error2 instanceof OutOfMemoryError))80throw error2;8182// Stack overflow is OK here.83}8485break;86}87return 0;88}8990static void recurse(int depth) {91if (depth > 0)92recurse(depth - 1);93}94}959697