test/compiler/7116216/StackOverflow.java

Tue, 20 Dec 2011 12:33:05 +0100

author
bdelsart
date
Tue, 20 Dec 2011 12:33:05 +0100
changeset 3372
dca455dea3a7
child 3407
35acf8f0a2e4
permissions
-rw-r--r--

7116216: StackOverflow GC crash
Summary: GC crash for explicit stack overflow checks after a C2I transition.
Reviewed-by: coleenp, never
Contributed-by: yang02.wang@sap.com, bertrand.delsart@oracle.com

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

mercurial