United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7148126 ConstantPoolCacheEntry::print prints to wrong stream
JDK-7148126 : ConstantPoolCacheEntry::print prints to wrong stream

Details
Type:
Bug
Submit Date:
2012-02-23
Status:
Closed
Updated Date:
2014-02-04
Project Name:
JDK
Resolved Date:
2012-03-07
Component:
hotspot
OS:
generic
Sub-Component:
runtime
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
8
Fixed Versions:
hs24 (b02)

Related Reports
Backport:
Backport:
Backport:

Sub Tasks

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

See suggested fix: use st instead of tty
                                     
2012-02-23
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 {
                                     
2012-02-23
EVALUATION

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

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

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



Hardware and Software, Engineered to Work Together