bdelsart@3372: /* bdelsart@3372: * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. bdelsart@3372: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. bdelsart@3372: * bdelsart@3372: * This code is free software; you can redistribute it and/or modify it bdelsart@3372: * under the terms of the GNU General Public License version 2 only, as bdelsart@3372: * published by the Free Software Foundation. bdelsart@3372: * bdelsart@3372: * This code is distributed in the hope that it will be useful, but WITHOUT bdelsart@3372: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or bdelsart@3372: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License bdelsart@3372: * version 2 for more details (a copy is included in the LICENSE file that bdelsart@3372: * accompanied this code). bdelsart@3372: * bdelsart@3372: * You should have received a copy of the GNU General Public License version bdelsart@3372: * 2 along with this work; if not, write to the Free Software Foundation, bdelsart@3372: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. bdelsart@3372: * bdelsart@3372: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA bdelsart@3372: * or visit www.oracle.com if you need additional information or have any bdelsart@3372: * questions. bdelsart@3372: * bdelsart@3372: */ bdelsart@3372: bdelsart@3372: /** bdelsart@3372: * @test bdelsart@3372: * @bug 7116216 bdelsart@3372: * @summary The vm crashes when GC happens during throwing a StackOverflow exception bdelsart@3372: * bdelsart@3372: * @run main/othervm -Xcomp -Xbatch StackOverflow bdelsart@3372: */ bdelsart@3372: bdelsart@3372: class StackOverflow { bdelsart@3372: static String stackOverflow_largeFrame_liveOopForGC; bdelsart@3372: bdelsart@3372: public static int stackOverflow_largeFrame(int call_count, String liveOopForGC) { bdelsart@3372: try { bdelsart@3372: int return_count = stackOverflow_largeFrame(++call_count, liveOopForGC); bdelsart@3372: if (return_count == 0) { bdelsart@3372: try { bdelsart@3372: LargeFrame.method_with_many_locals(liveOopForGC, 2,3,4,5,6,7,liveOopForGC); bdelsart@3372: } catch (StackOverflowError e2) { bdelsart@3372: // access liveOopForGC to make it a live variable bdelsart@3372: stackOverflow_largeFrame_liveOopForGC = liveOopForGC; bdelsart@3372: } bdelsart@3372: } bdelsart@3372: return return_count - 1; bdelsart@3372: } catch (StackOverflowError e) { bdelsart@3372: // Return a value that is large enough such that no unrecoverable bdelsart@3372: // stack overflow will occur afterwards, but that is small enough bdelsart@3372: // such that calling LargeFrame.method_with_many_locals() will bdelsart@3372: // cause a StackOverflowError. bdelsart@3372: // Don't use a call here because we're out of stack space anyway! bdelsart@3372: int tmp = call_count / 2; bdelsart@3372: return (tmp < 100 ? tmp : 100); bdelsart@3372: } bdelsart@3372: } bdelsart@3372: public static void main(String args[]) { bdelsart@3372: LargeFrame.method_with_many_locals(new Object(), 2,3,4,5,6,7,new Object()); bdelsart@3372: bdelsart@3372: stackOverflow_largeFrame(0, "this is a live oop to test GC"); bdelsart@3372: System.out.println("finished ok!"); bdelsart@3372: } bdelsart@3372: }