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

Kim Barrett kbarrett at openjdk.org
Wed Jul 30 08:22:57 UTC 2025


On Wed, 30 Jul 2025 07:24:49 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> The fix for [JDK-8361447](https://bugs.openjdk.org/browse/JDK-8361447) added a new field to the `GuardHeader`, not realizing that the size of the `GuardHeader` must be such that the address of the user-data has the strictest necessary alignment (16-byte).
>> 
>> We need to add a padding field to restore the alignment.
>> 
>> A static assert is added to check the alignment.
>> 
>> Testing:
>>  - tiers 1-3 (in progress)
>> 
>> Thanks
>
> 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.

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".

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26524#discussion_r2241892422
PR Review Comment: https://git.openjdk.org/jdk/pull/26524#discussion_r2241892261


More information about the hotspot-runtime-dev mailing list