JDK-8229808 : javaVFrame::print_lock_info_on fails to disable extra printing
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2019-08-16
  • Updated: 2019-08-27
  • Resolved: 2019-08-16
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 14
14 b11Fixed
Related Reports
Relates :  
Relates :  
Description
There's code that sets a markWord to 0 and expects extra printing to be disabled. However, the markWord is never used after that point, so either the comment is wrong or the disabling of extra printing is broken. See:

        markWord mark(markWord::zero);                                                                                                                                                                                                        
        const char *lock_state = "locked"; // assume we have the monitor locked                                                                                                                                                               
        if (!found_first_monitor && frame_count == 0) {                                                                                                                                                                                       
          // If this is the first frame and we haven't found an owned                                                                                                                                                                         
          // monitor before, then we need to see if we have completed                                                                                                                                                                         
          // the lock or if we are blocked trying to acquire it. Only                                                                                                                                                                         
          // an inflated monitor that is first on the monitor list in                                                                                                                                                                         
          // the first frame can block us on a monitor enter.                                                                                                                                                                                 
          mark = monitor->owner()->mark();                                                                                                                                                                                                    
          if (mark.has_monitor() &&                                                                                                                                                                                                           
              ( // we have marked ourself as pending on this monitor                                                                                                                                                                          
                mark.monitor() == thread()->current_pending_monitor() ||                                                                                                                                                                      
                // we are not the owner of this monitor                                                                                                                                                                                       
                !mark.monitor()->is_entered(thread())                                                                                                                                                                                         
              )) {                                                                                                                                                                                                                            
            lock_state = "waiting to lock";                                                                                                                                                                                                   
          } else {                                                                                                                                                                                                                            
            // We own the monitor which is not as interesting so                                                                                                                                                                              
            // disable the extra printing below.                                                                                                                                                                                              
            mark = markWord(markWord::zero);                                                                                                                                                                                                  
          }                                                                                                                                                                                                                                   
        }                                                                                                                                                                                                                                     
        print_locked_object_class_name(st, Handle(THREAD, monitor->owner()), lock_state);  
Comments
URL: https://hg.openjdk.java.net/jdk/jdk/rev/094ef5a91b68 User: dholmes Date: 2019-08-16 22:27:52 +0000
16-08-2019

The comment is wrong. The original code with disabled printing was added in JDK-8069412: + } else { + mark = NULL; // Disable printing below } } + print_locked_object_class_name(st, monitor->owner(), lock_state); + if (Verbose && mark != NULL) { + // match with format above, replacing "-" with " ". + st->print("\t lockbits="); + mark->print_on(st); + st->cr(); + } The use of the verbose flag was replaced by ObjectMonitor::Knob_verbose in JDK-8130448. Then the code was removed by JDK-8210848 "Obsolete SyncKnobs" - at which point the comments about "disable extra printing below" should have been removed.
16-08-2019

[~dholmes] - Nice spelunking on the history!
16-08-2019