# HG changeset patch # User lucy # Date 1550669894 -3600 # Node ID 58c4ddd5fe6091238d47f361ec45f6f66938af1e # Parent fe95464806a7500920f34057ed38123a0882907c 8219214: Infinite Loop in CodeSection::dump() Reviewed-by: diff --git a/src/hotspot/share/asm/codeBuffer.cpp b/src/hotspot/share/asm/codeBuffer.cpp --- a/src/hotspot/share/asm/codeBuffer.cpp +++ b/src/hotspot/share/asm/codeBuffer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -1030,20 +1030,22 @@ #ifndef PRODUCT void CodeSection::dump() { - address ptr = start(); - for (csize_t step; ptr < end(); ptr += step) { - step = end() - ptr; - if (step > jintSize * 4) step = jintSize * 4; - tty->print(INTPTR_FORMAT ": ", p2i(ptr)); - while (step > 0) { + address limit = end(); + csize_t bytes_per_blk = jintSize; + csize_t bytes_per_line = 4*bytes_per_blk; + + for (address ptr = start(); ptr < limit; ) { + csize_t bytes_to_print = (limit - ptr) < bytes_per_line ? (limit - ptr) : bytes_per_line; + tty->print(INTPTR_FORMAT ":", p2i(ptr)); + while (bytes_to_print >= bytes_per_blk) { // don't access data beyond end of range. tty->print(" " PTR32_FORMAT, *(jint*)ptr); - ptr += jintSize; + ptr += bytes_per_blk; + bytes_to_print -= bytes_per_blk; } tty->cr(); } } - void CodeSection::decode() { Disassembler::decode(start(), end()); }