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

Thomas Stuefe stuefe at openjdk.java.net
Thu Apr 7 18:00:23 UTC 2022


On Thu, 7 Apr 2022 09:26:48 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

>> Thomas Stuefe has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Alexey-feedback
>
> src/hotspot/share/runtime/os.cpp line 1680:
> 
>> 1678: static void assert_nonempty_range(const char* addr, size_t bytes) {
>> 1679:   assert(addr != nullptr && bytes > 0, "invalid range [" PTR_FORMAT ", " PTR_FORMAT ")",
>> 1680:          p2i(addr), p2i(addr + bytes));
> 
> I think `p2i(addr + bytes)` is UB when `addr` is `nullptr`? `p2i(addr) + bytes` is safer?

You are right. I fixed it.

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

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


More information about the hotspot-runtime-dev mailing list