8335664: Parsing jsr broken: assert(bci>= 0 && bci < c->method()->code_size()) failed: index out of bounds
Co-authored-by: Emanuel Peter <epeter@openjdk.org> Reviewed-by: dlong, thartmann
This commit is contained in:
parent
6cf7f9c4a7
commit
6041c936d6
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. 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
|
||||
@ -436,12 +436,12 @@ void GenerateOopMap::mark_bbheaders_and_count_gc_points() {
|
||||
/* We will also mark successors of jsr's as basic block headers. */
|
||||
switch (bytecode) {
|
||||
case Bytecodes::_jsr:
|
||||
assert(!fellThrough, "should not happen");
|
||||
bb_mark_fct(this, bci + Bytecodes::length_for(bytecode), nullptr);
|
||||
break;
|
||||
case Bytecodes::_jsr_w:
|
||||
assert(!fellThrough, "should not happen");
|
||||
bb_mark_fct(this, bci + Bytecodes::length_for(bytecode), nullptr);
|
||||
// If this is the last bytecode, there is no successor to mark
|
||||
if (bci + Bytecodes::length_for(bytecode) < method()->code_size()) {
|
||||
bb_mark_fct(this, bci + Bytecodes::length_for(bytecode), nullptr);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -502,7 +502,10 @@ void GenerateOopMap::mark_reachable_code() {
|
||||
case Bytecodes::_jsr:
|
||||
case Bytecodes::_jsr_w:
|
||||
assert(!fell_through, "should not happen");
|
||||
reachable_basicblock(this, bci + Bytecodes::length_for(bytecode), &change);
|
||||
// If this is the last bytecode, there is no successor to mark
|
||||
if (bci + Bytecodes::length_for(bytecode) < method()->code_size()) {
|
||||
reachable_basicblock(this, bci + Bytecodes::length_for(bytecode), &change);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -586,9 +589,6 @@ bool GenerateOopMap::jump_targets_do(BytecodeStream *bcs, jmpFct_t jmpFct, int *
|
||||
case Bytecodes::_jsr:
|
||||
assert(bcs->is_wide()==false, "sanity check");
|
||||
(*jmpFct)(this, bcs->dest(), data);
|
||||
|
||||
|
||||
|
||||
break;
|
||||
case Bytecodes::_jsr_w:
|
||||
(*jmpFct)(this, bcs->dest_w(), data);
|
||||
|
35
test/hotspot/jtreg/runtime/interpreter/LastJsr.jasm
Normal file
35
test/hotspot/jtreg/runtime/interpreter/LastJsr.jasm
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2024, Oracle and/or its affiliates. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
super public class LastJsr
|
||||
{
|
||||
public static Method test:"()V"
|
||||
stack 100 locals 100
|
||||
{
|
||||
return;
|
||||
LABEL:
|
||||
nop;
|
||||
jsr LABEL; // bci=2. Compute bci + length(jsr) -> bci = 5 accessed, out of bounds.
|
||||
}
|
||||
}
|
37
test/hotspot/jtreg/runtime/interpreter/LastJsrReachable.jasm
Normal file
37
test/hotspot/jtreg/runtime/interpreter/LastJsrReachable.jasm
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) 2024, Oracle and/or its affiliates. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
super public class LastJsrReachable
|
||||
{
|
||||
public static Method test:"()V"
|
||||
stack 100 locals 100
|
||||
{
|
||||
goto LB2;
|
||||
LABEL:
|
||||
return;
|
||||
LB2:
|
||||
nop;
|
||||
jsr LABEL;
|
||||
}
|
||||
}
|
40
test/hotspot/jtreg/runtime/interpreter/LastJsrTest.java
Normal file
40
test/hotspot/jtreg/runtime/interpreter/LastJsrTest.java
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2024, Oracle and/or its affiliates. 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
|
||||
* @bug 8335664
|
||||
* @summary Ensure a program that ends with a JSR does not crash
|
||||
* @library /test/lib
|
||||
* @compile LastJsr.jasm
|
||||
* @compile LastJsrReachable.jasm
|
||||
* @run main/othervm LastJsrTest
|
||||
*/
|
||||
|
||||
public class LastJsrTest {
|
||||
public static void main(String[] args) {
|
||||
LastJsr.test();
|
||||
LastJsrReachable.test();
|
||||
System.out.println("PASSED");
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user