RFR: 8303942: FileMapInfo::write_bytes aborts on a short os::write
Afshin Zafari
duke at openjdk.org
Mon Apr 3 09:18:38 UTC 2023
On Mon, 3 Apr 2023 00:46:36 GMT, Ioi Lam <iklam at openjdk.org> wrote:
> We have other cases that assumes that `os::write` writes all the requested bytes:
>
> https://github.com/openjdk/jdk/blob/aa762102e9328ca76663b56b3be6f6141b044744/src/hotspot/share/jfr/recorder/repository/jfrEmergencyDump.cpp#L379-L389
>
> Writing a loop for each case will be messy and buggy. It's better to get rid of `os::write()` and replace it with `os::write_fully()`.
>
> ```
> size_t bytes_written = os::write_fully(fd, buffer, bytes_requested);
> if (bytes_written != bytes_requested) {
> // report error ....
> }
> ```
>
> and I can't understand why `os::write` takes an `unsigned int`!
>
> https://github.com/openjdk/jdk/blob/aa762102e9328ca76663b56b3be6f6141b044744/src/hotspot/os/posix/os_posix.cpp#L774-L778
For the `signed` and `unsigned` question, please refer to my reply to David's comment above.
All cases that found are:
#### using `write()` in loop:
src/hotspot/os/posix/perfMemory_posix.cpp
src/hotspot/share/jfr/writers/jfrStreamWriterHost.inline.hpp
src/hotspot/share/services/heapDumperCompression.cpp
#### buggy use of `write()`:
src/hotspot/share/jfr/recorder/repository/jfrEmergencyDump.cpp
src/hotspot/share/prims/jvm.cpp (Issue 8303943 is already created for it)
src/hotspot/share/cds/filemap.cpp (The current issue is for it)
So, shall we create a new issue for the remaining buggy case and then create another issue for replacing all the loop cases with a new `write_fully()`? Or do all these in one new issue?
-------------
PR Comment: https://git.openjdk.org/jdk/pull/13188#issuecomment-1493939178
More information about the hotspot-runtime-dev
mailing list