- 
    
Bug
 - 
    Resolution: Fixed
 - 
    
  P3                     
     - 
    11.0.14, 15, 16, 17, 18, 19, 20, 21
 
| Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build | 
|---|---|---|---|---|---|---|
| JDK-8307012 | 20u-cpu | Man Cao | P3 | Resolved | Fixed | master | 
| JDK-8304227 | 20.0.2 | Man Cao | P3 | Resolved | Fixed | b03 | 
| JDK-8310612 | 17.0.9-oracle | Joe Cherian | P3 | Resolved | Fixed | b01 | 
| JDK-8304233 | 17.0.8 | Man Cao | P3 | Resolved | Fixed | b01 | 
| JDK-8304234 | 11.0.20 | Man Cao | P3 | Resolved | Fixed | b01 | 
The root cause is in FileWriter::write_buf() in heapDumperCompression.cpp, for n = os::write(_fd, buf, (uint) size); n could be > 0 but smaller than size. In this case, there should be a loop to retry os::write() for the remaining bytes in buf. There was such a loop in DumpWriter::write_internal() before
This problem is well documented in the man page for write(): https://man7.org/linux/man-pages/man2/write.2.html#RETURN_VALUE.
In our case, we see the corruption frequently because we support dumping heap to a socket or pipe.
- backported by
 - 
                    
JDK-8304227 Corrupted heap dumps due to missing retries for os::write()
-         
     - Resolved
 
 -         
 - 
                    
JDK-8304233 Corrupted heap dumps due to missing retries for os::write()
-         
     - Resolved
 
 -         
 - 
                    
JDK-8304234 Corrupted heap dumps due to missing retries for os::write()
-         
     - Resolved
 
 -         
 - 
                    
JDK-8307012 Corrupted heap dumps due to missing retries for os::write()
-         
     - Resolved
 
 -         
 - 
                    
JDK-8310612 Corrupted heap dumps due to missing retries for os::write()
-         
     - Resolved
 
 -         
 
- relates to
 - 
                    
JDK-8303942 os::write should write completely
-         
     - Resolved
 
 -         
 - 
                    
JDK-8316468 os::write incorrectly handles partial write
-         
     - Closed
 
 -         
 - 
                    
JDK-8303943 jio_print doesn't allow for a short os::write
-         
     - Closed
 
 -         
 - 
                    
JDK-8237354 Add option to jcmd to write a gzipped heap dump
-         
     - Resolved
 
 -         
 
- links to
 - 
                    
        
        Commit
        openjdk/jdk11u-dev/97809afd
    
 - 
                    
        
        Commit
        openjdk/jdk17u-dev/bc79161e
    
 - 
                    
        
        Commit
        openjdk/jdk20u/e7e1b5fd
    
 - 
                    
        
        Commit
        openjdk/jdk/bf16b5b9
    
 - 
                    
        
        Review
        openjdk/jdk11u-dev/1801
    
 - 
                    
        
        Review
        openjdk/jdk17u-dev/1201
    
 - 
                    
        
        Review
        openjdk/jdk20u/18
    
 - 
                    
        
        Review
        openjdk/jdk/12966