RFR: 8346157: [Ubsan]: runtime error: pointer index expression with base 0x000000001000 overflowed to 0xfffffffffffffff0 [v2]

Thomas Stuefe stuefe at openjdk.org
Fri Jan 3 07:56:34 UTC 2025


On Fri, 3 Jan 2025 06:38:48 GMT, Amit Kumar <amitkumar at openjdk.org> wrote:

>> Fixes ubsan warning in mallocTracker.cpp
>
> Amit Kumar has updated the pull request incrementally with one additional commit since the last revision:
> 
>   cast to void* instead of int8_t*

The overflow is not fixed with a conversion to an integral, right? We just mute UBSAN that way.

The correct way would be to cap `end` at 0.

Instead, or in addition to that, I would bail out right away at the start of the function if the pointer is smaller than a reasonable minimum. Or, even better, at the start of `os::print_location`.

A reasonable minimum would be `os::vm_min_address()`. We should never see mappings lower than that. Since on Linux this is an OS-side setting that can be adjusted theoretically to 0 (I think), I would combine that with a hard minimum, e.g.


if (p2u(addr) < MAX2(os::vm_min_address(), 16 * M) {
  return;
}

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

PR Review: https://git.openjdk.org/jdk/pull/22885#pullrequestreview-2528672444


More information about the hotspot-runtime-dev mailing list