Skip to content

Commit fbdc187

Browse files
author
Vladimir Ivanov
committedDec 4, 2020
8257624: C2: PhaseMacroExpand::eliminate_macro_nodes() crashes on out-of-bounds access into macro node array
Reviewed-by: neliasso, kvn
1 parent fd6756e commit fbdc187

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed
 

‎src/hotspot/share/opto/macro.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -2564,7 +2564,10 @@ void PhaseMacroExpand::eliminate_macro_nodes() {
25642564
while (progress) {
25652565
progress = false;
25662566
for (int i = C->macro_count(); i > 0; i--) {
2567-
Node * n = C->macro_node(i-1);
2567+
if (i > C->macro_count()) {
2568+
i = C->macro_count(); // more than 1 element can be eliminated at once
2569+
}
2570+
Node* n = C->macro_node(i-1);
25682571
bool success = false;
25692572
DEBUG_ONLY(int old_macro_count = C->macro_count();)
25702573
if (n->is_AbstractLock()) {
@@ -2580,7 +2583,10 @@ void PhaseMacroExpand::eliminate_macro_nodes() {
25802583
while (progress) {
25812584
progress = false;
25822585
for (int i = C->macro_count(); i > 0; i--) {
2583-
Node * n = C->macro_node(i-1);
2586+
if (i > C->macro_count()) {
2587+
i = C->macro_count(); // more than 1 element can be eliminated at once
2588+
}
2589+
Node* n = C->macro_node(i-1);
25842590
bool success = false;
25852591
DEBUG_ONLY(int old_macro_count = C->macro_count();)
25862592
switch (n->class_id()) {

0 commit comments

Comments
 (0)
Please sign in to comment.