RFR: 8360941: [ubsan] MemRegion::end() shows runtime error: applying non-zero offset 8388608 to null pointer [v6]

Thomas Stuefe stuefe at openjdk.org
Tue Jul 22 07:49:42 UTC 2025


On Mon, 21 Jul 2025 21:33:27 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

>> Matthias Baesken has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Suggestion by Thomas Stuefe
>
> test/hotspot/gtest/gc/g1/test_freeRegionList.cpp line 50:
> 
>> 48:   const size_t sz = szw * BytesPerWord;
>> 49:   char* addr = os::reserve_memory(sz, mtTest);
>> 50:   MemRegion heap((HeapWord*)addr, szw);
> 
> So far as I can tell, there's no guarantee that `os::reserve_memory` will return an address with any
> particular alignment. Since the earlier attempt with unaligned storage failed, it may only be by accident
> that this isn't failing as well.  We have `os::reserve_memory_aligned`, or could add an extra region to
> the desired size and align up the result.

`os::reserve_memory` addresses are always regular-page-aligned. But `os::reserve_memory_aligned` may be better here since I guess the addresses would better have been region-size-aligned, so aligned to G1HeapRegion::GrainWords. That could be larger than system page size.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26216#discussion_r2221537409


More information about the hotspot-runtime-dev mailing list