RFR: 8281213: Unsafe uses of long and size_t in MemReporterBase::diff_in_current_scale
Thomas Stuefe
stuefe at openjdk.org
Wed Dec 7 14:30:05 UTC 2022
On Wed, 7 Dec 2022 14:08:38 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
> I would return `ssize_t` instead.
>
> For values >`SSIZE_MAX` and <`SSIZE_MIN` I would assert in debug (because we should never see such high numbers) and cap in release builds.
>
> And of course, the print format has to be adapted to use ssize_t format
Correcting myself:
I would return int64_t (signed 64-bit).
On 32-bit platforms, where we could conceivably surpass SSIZE_MAX and SSIZE_MIN, that is large enough to hold positive and negative deltas.
On 64-bit, int64_t is the same as ssize_t. There, as I proposed, I would consider any delta > SSIZE_MIN or SSIZE_MAX to be an error. Because that indicates a negative overflow in a malloc counter.
I would actually consider any input value > 1000 TB an error as well, certainly any input > SSIZE_MAX.
-------------
PR: https://git.openjdk.org/jdk/pull/11514
More information about the hotspot-runtime-dev
mailing list