Path: blob/master/test/hotspot/jtreg/compiler/interpreter/cr7116216/StackOverflow.java
41153 views
/*1* Copyright (c) 2011, 2012, 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* @bug 711621626* @summary The vm crashes when GC happens during throwing a StackOverflow exception27* @library /28* @run main/othervm -Xcomp -Xbatch compiler.interpreter.cr7116216.StackOverflow29*/3031package compiler.interpreter.cr7116216;3233public class StackOverflow {34static String stackOverflow_largeFrame_liveOopForGC;3536public static int stackOverflow_largeFrame(int call_count, String liveOopForGC) {37try {38int return_count = stackOverflow_largeFrame(++call_count, liveOopForGC);39if (return_count == 0) {40try {41LargeFrame.method_with_many_locals(liveOopForGC, 2,3,4,5,6,7,liveOopForGC);42} catch (StackOverflowError e2) {43// access liveOopForGC to make it a live variable44stackOverflow_largeFrame_liveOopForGC = liveOopForGC;45}46}47return return_count - 1;48} catch (StackOverflowError e) {49// Return a value that is large enough such that no unrecoverable50// stack overflow will occur afterwards, but that is small enough51// such that calling LargeFrame.method_with_many_locals() will52// cause a StackOverflowError.53// Don't use a call here because we're out of stack space anyway!54int tmp = call_count / 2;55return (tmp < 100 ? tmp : 100);56}57}58public static void main(String args[]) {59LargeFrame.method_with_many_locals(new Object(), 2,3,4,5,6,7,new Object());6061stackOverflow_largeFrame(0, "this is a live oop to test GC");62System.out.println("finished ok!");63}64}656667