JDK-7148126 : ConstantPoolCacheEntry::print prints to wrong stream
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 8
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2012-02-23
  • Updated: 2014-02-04
  • Resolved: 2012-03-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7 JDK 8 Other
7u40Fixed 8Fixed hs24Fixed
Description
A minor issue:
Running experiments that crash the VM lead me to some weird output on stdout during VM error reporting [1].

Turns out it's from ConstantPoolCacheEntry::print(outputStream* st, int index). But instead of printing to "st", it's printing to "tty".

The call path:

os::print_register_info(outputStream *st, void *context)
  os::print_location(outputStream* st, intptr_t x, bool verbose)
    oopDesc::print_on(outputStream* st)
      constantPoolCacheKlass::oop_print_on(oop obj, outputStream* st)
        ConstantPoolCacheEntry::print(outputStream* st, int index)

I checked that the last function is the only one not using the "st" argument.

A patch to fix it, diff against jdk8/jdk8/hotspot master: [2]
Could anyone please sponsor this patch?

Regards,
Kris Mok

[1]: https://gist.github.com/1891517#file_command_prompt
[2]: https://gist.github.com/1891517#file_fix_against_jdk8_master.patch

Comments
EVALUATION http://hg.openjdk.java.net/lambda/lambda/hotspot/rev/f096e1b74d85
22-03-2012

EVALUATION http://hg.openjdk.java.net/hsx/hotspot-main/hotspot/rev/f096e1b74d85
29-02-2012

EVALUATION http://hg.openjdk.java.net/hsx/hotspot-rt/hotspot/rev/f096e1b74d85
25-02-2012

SUGGESTED FIX diff -r 3b24e7e01d20 src/share/vm/oops/cpCacheOop.cpp --- a/src/share/vm/oops/cpCacheOop.cpp Mon Feb 20 22:32:30 2012 -0800 +++ b/src/share/vm/oops/cpCacheOop.cpp Thu Feb 23 16:27:25 2012 +0800 @@ -504,17 +504,17 @@ void ConstantPoolCacheEntry::print(outputStream* st, int index) const { // print separator - if (index == 0) tty->print_cr(" -------------"); + if (index == 0) st->print_cr(" -------------"); // print entry - tty->print("%3d ("PTR_FORMAT") ", index, (intptr_t)this); + st->print("%3d ("PTR_FORMAT") ", index, (intptr_t)this); if (is_secondary_entry()) - tty->print_cr("[%5d|secondary]", main_entry_index()); + st->print_cr("[%5d|secondary]", main_entry_index()); else - tty->print_cr("[%02x|%02x|%5d]", bytecode_2(), bytecode_1(), constant_pool_index()); - tty->print_cr(" [ "PTR_FORMAT"]", (intptr_t)(oop)_f1); - tty->print_cr(" [ "PTR_FORMAT"]", (intptr_t)_f2); - tty->print_cr(" [ "PTR_FORMAT"]", (intptr_t)_flags); - tty->print_cr(" -------------"); + st->print_cr("[%02x|%02x|%5d]", bytecode_2(), bytecode_1(), constant_pool_index()); + st->print_cr(" [ "PTR_FORMAT"]", (intptr_t)(oop)_f1); + st->print_cr(" [ "PTR_FORMAT"]", (intptr_t)_f2); + st->print_cr(" [ "PTR_FORMAT"]", (intptr_t)_flags); + st->print_cr(" -------------"); } void ConstantPoolCacheEntry::verify(outputStream* st) const {
23-02-2012

EVALUATION See suggested fix: use st instead of tty
23-02-2012