Skip to content

Commit 4f283f1

Browse files
committed
8373820: C2: Robust Node::uncast_helper infinite loop check
Reviewed-by: qamai, chagedorn
1 parent d8eb125 commit 4f283f1

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/hotspot/share/opto/node.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -999,18 +999,22 @@ bool Node::has_out_with(int opcode1, int opcode2, int opcode3, int opcode4) {
999999
//---------------------------uncast_helper-------------------------------------
10001000
Node* Node::uncast_helper(const Node* p, bool keep_deps) {
10011001
#ifdef ASSERT
1002+
// If we end up traversing more nodes than we actually have,
1003+
// it is definitely an infinite loop.
1004+
uint max_depth = Compile::current()->unique();
10021005
uint depth_count = 0;
10031006
const Node* orig_p = p;
10041007
#endif
10051008

10061009
while (true) {
10071010
#ifdef ASSERT
1008-
if (depth_count >= K) {
1011+
if (depth_count++ >= max_depth) {
10091012
orig_p->dump(4);
1010-
if (p != orig_p)
1013+
if (p != orig_p) {
10111014
p->dump(1);
1015+
}
1016+
fatal("infinite loop in Node::uncast_helper");
10121017
}
1013-
assert(depth_count++ < K, "infinite loop in Node::uncast_helper");
10141018
#endif
10151019
if (p == nullptr || p->req() != 2) {
10161020
break;

0 commit comments

Comments
 (0)