[jdk17u-dev] RFR: 8332825: ubsan: guardedMemory.cpp:35:11: runtime error: null pointer passed as argument 2, which is declared to never be null
Thomas Stuefe
stuefe at openjdk.org
Thu Sep 12 09:35:07 UTC 2024
On Thu, 12 Sep 2024 09:09:57 GMT, Goetz Lindenmaier <goetz at openjdk.org> wrote:
>> src/hotspot/share/memory/guardedMemory.cpp line 38:
>>
>>> 36: if (ptr != nullptr) {
>>> 37: memcpy(innerp, ptr, len);
>>> 38: }
>>
>> Hmm. innerp can never be null. If anything, we should assert.
>
> Hi,
> I don't understand. First, innerp is not checked for null. Second: does the code in 17 differ to 21&head? Else we should change this to an assertion in head, first.
Hi Goetz!
`innerp` is the result of
u_char* get_user_ptr() const {
assert(_base_addr != nullptr, "Not wrapping any memory");
return _base_addr + sizeof(GuardHeader);
}
which cannot return null. _base_addr is the result of a malloc and we only ever enter this path if that malloc succeeded. It is also asserted at least twice.
Cheers, Thomas
-------------
PR Review Comment: https://git.openjdk.org/jdk17u-dev/pull/2829#discussion_r1756499855
More information about the jdk-updates-dev
mailing list