RFR: 8360941: [ubsan] MemRegion::end() shows runtime error: applying non-zero offset 8388608 to null pointer [v3]
Matthias Baesken
mbaesken at openjdk.org
Wed Jul 16 14:45:06 UTC 2025
On Fri, 11 Jul 2025 17:25:50 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:
>> src/hotspot/share/memory/memRegion.hpp line 67:
>>
>>> 65: HeapWord* start() const { return _start; }
>>> 66: // in the gtests we call end() with a _start == nullptr so adjust the addition to avoid ub
>>> 67: HeapWord* end() const { return reinterpret_cast<HeapWord*>(reinterpret_cast<uintptr_t>(_start) + (_word_size * sizeof(HeapWord))); }
>>
>> I don't think this change should be made. Instead, fix the offending test. The fake heap it creates starts
>> at null, but I think it could be anywhere, because nothing touches it.
>
> If it did (or does) need to be valid memory, then just allocate a chunk of
> native memory for this fake heap for the test. That might be the safer thing
> to do anyway, in case some future change leads to the fake region getting
> touched.
> I don't think this change should be made. Instead, fix the offending test. The fake heap it creates starts at null, but I think it could be anywhere, because nothing touches it.
Let's do it this way !
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26216#discussion_r2210636582
More information about the hotspot-runtime-dev
mailing list