[jdk18] RFR: 8279011: JFR: JfrChunkWriter incorrectly handles int64_t chunk size as size_t
Aleksey Shipilev
shade at openjdk.java.net
Mon Dec 20 16:41:40 UTC 2021
See the investigation in the bug.
Spot the problem:
int64_t JfrChunkWriter::write_chunk_header_checkpoint(bool flushpoint) {
...
const size_t sz_written = size_written(); // <-- returns int64_t
write_be_at_offset(sz_written, chunk_size_offset); // <--- template instantiation with type=size_t
return sz_written;
}
This would have been nearly fine -- small `size_t` -> `int64_t` conversion is okay value-wise. But `write_be_at_offset` calculates the position for the writeout using `sizeof(T)`, which silently borks the whole thing on at least 32-bit platforms, where `sizeof(size_t)` != `sizeof(int64_t)`.
Additional testing:
- [x] Linux x86_64 `jdk_jfr` (no regressions)
- [x] Linux x86_32 `jdk_jfr` (many failing tests now pass)
-------------
Commit messages:
- Fix
Changes: https://git.openjdk.java.net/jdk18/pull/50/files
Webrev: https://webrevs.openjdk.java.net/?repo=jdk18&pr=50&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8279011
Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
Patch: https://git.openjdk.java.net/jdk18/pull/50.diff
Fetch: git fetch https://git.openjdk.java.net/jdk18 pull/50/head:pull/50
PR: https://git.openjdk.java.net/jdk18/pull/50
More information about the hotspot-jfr-dev
mailing list