RFR: 8364235: Fix for JDK-8361447 breaks the alignment requirements for GuardedMemory [v4]

David Holmes dholmes at openjdk.org
Sun Aug 3 22:47:04 UTC 2025


On Wed, 30 Jul 2025 08:19:52 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

>> David Holmes has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   typo
>
> src/hotspot/share/memory/guardedMemory.hpp line 48:
> 
>> 46:  * |+sizeof(size_t)    | <tag>                | Tag word       |
>> 47:  * |+sizeof(void*)     | <tag2>               | Tag word       |
>> 48:  * |+sizeof(void*)     | 0xF1 <user_data> (   | User data      |
> 
> There's no mention of potential (and now actual) padding between <tag2> and <user_data> in this table.

Good point. I will add something.

> src/hotspot/share/memory/guardedMemory.hpp line 141:
> 
>> 139:    * to achieve this.
>> 140:    */
>> 141:   class alignas(16) GuardHeader : Guard {
> 
> Consider `alignas(std::max_align_t)`, since we're claiming it needs to be "maximally aligned".

But apparently `max_align_t` does not provide that - it provides the maximal alignment for scalar types, but "new-alignment" can be greater and it seems on Windows that is the case: we allocate at 16-byte alignment but `max_align_t` only has 8-byte alignment!

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26524#discussion_r2250163963
PR Review Comment: https://git.openjdk.org/jdk/pull/26524#discussion_r2250163812


More information about the hotspot-runtime-dev mailing list