JDK-8316468 : os::write incorrectly handles partial write
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 21
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2023-09-19
  • Updated: 2024-06-07
  • Resolved: 2023-09-19
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 17 JDK 21 JDK 22
17.0.13Fixed 21.0.2Fixed 22 b16Fixed
Related Reports
Relates :  
Relates :  
Description
JDK-8303942 introduced a bug in os::write() in os.cpp for handling partial write:
```
buf = (void *)((char *)buf + nBytes);
```
should be

```
buf = (void *)((char *)buf + res);
```

We observed that in JDK 21, heap dump corruption observed in JDK-8303937 happens again when writing to a socket or pipe.
Comments
[jdk17u-fix-request] Approval Request from Elif Aslan clean backport to address a regression in os::write() that could cause heap dump corruption. Testing: hotspot,jfr and GHA tests passed.
29-05-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk17u-dev/pull/2490 Date: 2024-05-23 19:33:35 +0000
29-05-2024

Thank you for fixing this and for the backport to JDK 21u.
20-09-2023

The tag for 21u should be jdk21u-fix-request, FTFY. :)
20-09-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk21u/pull/176 Date: 2023-09-20 07:57:33 +0000
20-09-2023

Fix Request (21u): It fixes a bug that could cause file corruption such as in heap dumps. The fix is a one-line change and applies cleanly. Risk is low. Passes pre-submit tier1 tests.
20-09-2023

Changeset: 7ce5bd15 Author: Man Cao <manc@openjdk.org> Date: 2023-09-19 20:06:40 +0000 URL: https://git.openjdk.org/jdk/commit/7ce5bd159024e70f5a997c47ed2ce962d6e6091b
19-09-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/15808 Date: 2023-09-19 01:55:48 +0000
19-09-2023