test/hotspot/jtreg/runtime/Safepoint/TestAbortVMOnSafepointTimeout.java
author mdoerr
Fri, 08 Mar 2019 11:23:30 +0100
changeset 54031 feea57b38a1c
child 57598 80ba2f1cdd4d
permissions -rw-r--r--
8219584: Try to dump error file by thread which causes safepoint timeout Reviewed-by: stuefe, dholmes, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
54031
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
     1
/*
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
     2
 * Copyright (c) 2019, SAP SE. All rights reserved.
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
     4
 *
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
     7
 * published by the Free Software Foundation.
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
     8
 *
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    13
 * accompanied this code).
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    14
 *
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    18
 *
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    21
 * questions.
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    22
 */
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    23
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    24
import jdk.test.lib.*;
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    25
import jdk.test.lib.process.*;
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    26
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    27
/*
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    28
 * @test TestAbortVMOnSafepointTimeout
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    29
 * @summary Check if VM can kill thread which doesn't reach safepoint.
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    30
 * @bug 8219584
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    31
 * @requires vm.compiler2.enabled
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    32
 * @library /test/lib
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    33
 * @modules java.base/jdk.internal.misc
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    34
 *          java.management
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    35
 */
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    36
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    37
public class TestAbortVMOnSafepointTimeout {
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    38
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    39
    public static void main(String[] args) throws Exception {
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    40
        if (args.length > 0) {
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    41
            int result = test_loop(3);
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    42
            System.out.println("This message would occur after some time with result " + result);
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    43
            return;
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    44
        }
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    45
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    46
        testWith(500, 500);
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    47
    }
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    48
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    49
    static int test_loop(int x) {
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    50
        int sum = 0;
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    51
        if (x != 0) {
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    52
            // Long running loop without safepoint.
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    53
            for (int y = 1; y < Integer.MAX_VALUE; ++y) {
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    54
                if (y % x == 0) ++sum;
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    55
            }
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    56
        }
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    57
        return sum;
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    58
    }
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    59
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    60
    public static void testWith(int sfpt_interval, int timeout_delay) throws Exception {
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    61
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    62
                "-XX:+UnlockDiagnosticVMOptions",
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    63
                "-XX:+SafepointTimeout",
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    64
                "-XX:+SafepointALot",
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    65
                "-XX:+AbortVMOnSafepointTimeout",
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    66
                "-XX:SafepointTimeoutDelay=" + timeout_delay,
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    67
                "-XX:GuaranteedSafepointInterval=" + sfpt_interval,
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    68
                "-XX:-TieredCompilation",
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    69
                "-XX:-UseCountedLoopSafepoints",
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    70
                "-XX:LoopStripMiningIter=0",
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    71
                "-XX:LoopUnrollLimit=0",
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    72
                "-XX:CompileCommand=compileonly,TestAbortVMOnSafepointTimeout::test_loop",
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    73
                "-Xcomp",
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    74
                "-XX:-CreateCoredumpOnCrash",
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    75
                "-Xms64m",
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    76
                "TestAbortVMOnSafepointTimeout",
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    77
                "runTestLoop"
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    78
        );
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    79
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    80
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    81
        if (Platform.isWindows()) {
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    82
            output.shouldMatch("Safepoint sync time longer than");
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    83
        } else {
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    84
            output.shouldMatch("SIGILL");
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    85
            if (Platform.isLinux()) {
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    86
                output.shouldMatch("(sent by kill)");
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    87
            }
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    88
            output.shouldMatch("TestAbortVMOnSafepointTimeout.test_loop");
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    89
        }
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    90
        output.shouldNotHaveExitValue(0);
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    91
    }
feea57b38a1c 8219584: Try to dump error file by thread which causes safepoint timeout
mdoerr
parents:
diff changeset
    92
}