RFR: 8331731: ubsan: relocInfo.cpp:155:30: runtime error: applying non-zero offset 18446744073709551614 to null pointer [v3]

Martin Doerr mdoerr at openjdk.org
Fri May 31 09:51:03 UTC 2024


On Fri, 31 May 2024 08:04:27 GMT, Matthias Baesken <mbaesken at openjdk.org> wrote:

>> When running on macOS with ubsan enabled, we see some issues in relocInfo  (hpp and cpp); those already occur in the build quite early.
>> 
>> /jdk/src/hotspot/share/code/relocInfo.cpp:155:30: runtime error: applying non-zero offset 18446744073709551614 to null pointer
>> 
>> Similar happens when we add to the _current pointer
>>     _current++;
>> this gives :
>> relocInfo.hpp:606:13: runtime error: applying non-zero offset to non-null pointer 0xfffffffffffffffe produced null pointer
>> 
>> Seems the pointer subtraction/addition worked so far, so it might be an option to disable ubsan for those 2 functions.
>
> Matthias Baesken has updated the pull request incrementally with one additional commit since the last revision:
> 
>   rename templates

I guess Matthias only wanted to fix UB in hotspot ASAP and doesn't have the bandwidth to change the design everywhere. Sounds like you guys already have an alternative solution which already works. Maybe you would like to put it into a PR and we continue the discussion there?
Nevertheless, having `sub / add_to_ptr_maybe_null` available in hotspot may be a good thing. There are some places where we really use additions with nullptr (e.g. `index_oop_from_field_offset_long` in unsafe.cpp).

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

PR Comment: https://git.openjdk.org/jdk/pull/19424#issuecomment-2141637028


More information about the hotspot-compiler-dev mailing list