RFR: 8331626: unsafe.cpp:162:38: runtime error in index_oop_from_field_offset_long - applying non-zero offset 4563897424 to null pointer [v2]

Stefan Karlsson stefank at openjdk.org
Mon May 6 14:33:52 UTC 2024


On Mon, 6 May 2024 09:38:55 GMT, Martin Doerr <mdoerr at openjdk.org> wrote:

>> src/hotspot/share/prims/unsafe.cpp line 158:
>> 
>>> 156:   assert_field_offset_sane(p, field_offset);
>>> 157:   uintptr_t base_address = cast_from_oop<uintptr_t>(p),
>>> 158:             byte_offset  = (uintptr_t)field_offset_to_byte_offset(field_offset);
>> 
>> We tend to not use this style for setting up variables in HotSpot code: I propose that you update the code to:
>> Suggestion:
>> 
>>   uintptr_t base_address = cast_from_oop<uintptr_t>(p);
>>   uintptr_t byte_offset  = (uintptr_t)field_offset_to_byte_offset(field_offset);
>
> I couldn't find that in the hotspot style guide. Is that documented anywhere? We sometimes use it. Nevertheless, I've changed it.

I think I've read it somewhere, but I can't find it. I would prefer if we didn't use it in shared code.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/19087#discussion_r1591100786


More information about the hotspot-dev mailing list