Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8271055: Crash during deoptimization with "assert(bb->is_reachable()) failed: getting result from unreachable basicblock" with -XX:+VerifyStack #4902

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/hotspot/share/oops/generateOopMap.cpp
Expand Up @@ -1171,8 +1171,11 @@ void GenerateOopMap::interp_bb(BasicBlock *bb) {
}

void GenerateOopMap::do_exception_edge(BytecodeStream* itr) {
// Only check exception edge, if bytecode can trap
if (!Bytecodes::can_trap(itr->code())) return;
// Check exception edge even if bytecode can not trap since some bytecodes
// in try-block will never throw an exception, thus exception handler basic
// blocks becomes unreachable. For such cases, these unreachable basic blocks
// confuse later OopMap generation.

switch (itr->code()) {
case Bytecodes::_aload_0:
// These bytecodes can trap for rewriting. We need to assume that
Expand Down
Expand Up @@ -1518,6 +1518,11 @@ void genTry(JCTree body, List<JCCatch> catchers, Env<GenContext> env) {
int startpc = code.curCP();
Code.State stateTry = code.state.dup();
genStat(body, env, CRT_BLOCK);
if (startpc == code.curCP()) {
// Put a "nop" into try block even if it is empty because we want
// to generate exception table within code attribute.
code.emitop0(nop);
}
int endpc = code.curCP();
List<Integer> gaps = env.info.gaps.toList();
code.statBegin(TreeInfo.endPos(body));
Expand Down
@@ -0,0 +1,52 @@
/*
* Copyright (c) 2021, Alibaba Group Holding Limited. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/

/*
* @test VerifyStackWithUnreachableBlock
* @bug 8271055
* @compile VerifyStackWithUnreachableBlock.java
* @summary Using VerifyStack for method that contains unreachable basic blocks
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+VerifyStack compiler.interpreter.VerifyStackWithUnreachableBlock
*/

package compiler.interpreter;

public class VerifyStackWithUnreachableBlock {
public static void main(String[] strArr) {
VerifyStackWithUnreachableBlock _instance = new VerifyStackWithUnreachableBlock();
for (int i = 0; i < 10000; i++) {
_instance.test();
}
}

void test() {
int i8 = 1;
try {
;
} finally {
for (; i8 < 100; i8++) {
}
}
}
}