RFR: JDK-8284178: os::commit_memory() should assert the given range [v2]

Aleksey Shipilev shade at openjdk.java.net
Thu Apr 7 06:10:41 UTC 2022


On Thu, 7 Apr 2022 04:42:47 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

>> src/hotspot/share/runtime/os.cpp line 1679:
>> 
>>> 1677: 
>>> 1678: static void assert_nonempty_range(const char* addr, size_t bytes) {
>>> 1679:   assert(addr != nullptr && bytes > 0, "invalid range (" PTR_FORMAT ", " SIZE_FORMAT ")",
>> 
>> The message suggests it is *range*, i.e. `(begin, end)`. I wonder if we better print `p2i(addr) + bytes`?
>
> Okay, I changed the message

I think `p2i(addr + bytes)` is UB when `addr` is `nullptr`? `p2i(addr) + bytes` is safer?

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

PR: https://git.openjdk.java.net/jdk/pull/8075


More information about the hotspot-runtime-dev mailing list