[jdk18] Integrated: 8279011: JFR: JfrChunkWriter incorrectly handles int64_t chunk size as size_t

Aleksey Shipilev shade at openjdk.java.net
Tue Dec 21 12:36:29 UTC 2021


On Mon, 20 Dec 2021 16:34:07 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

> 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)

This pull request has now been integrated.

Changeset: 467f6549
Author:    Aleksey Shipilev <shade at openjdk.org>
URL:       https://git.openjdk.java.net/jdk18/commit/467f654916764751746934f80877d49a5f107194
Stats:     1 line in 1 file changed: 0 ins; 0 del; 1 mod

8279011: JFR: JfrChunkWriter incorrectly handles int64_t chunk size as size_t

Reviewed-by: mgronlun

-------------

PR: https://git.openjdk.java.net/jdk18/pull/50


More information about the hotspot-jfr-dev mailing list