RFR: 8346714: [ASAN] compressedKlass.cpp reported applying non-zero offset to null pointer [v4]

Martin Doerr mdoerr at openjdk.org
Mon Dec 23 09:44:36 UTC 2024


On Mon, 23 Dec 2024 09:15:33 GMT, SendaoYan <syan at openjdk.org> wrote:

>> src/hotspot/share/oops/compressedKlass.cpp line 99:
>> 
>>> 97:   // Check that Klass range is fully engulfed in the encoding range
>>> 98:   const address encoding_start = _base;
>>> 99:   const address encoding_end = (address)(p2u(_base) + (uintptr_t)nth_bit(narrow_klass_pointer_bits() + _shift));
>> 
>> nth_bit should already give us a 64-bit value, why the second cast?
>> I see that nth_bit returns an intptr_t - is the sign the problem? We may want to change that to uintptr_t...
>
> Prefer using `uintptr_t` because `intptr_t` has undefined behavior on overflow. Probably not in this case, here.

It should work without the second cast, but there may be compiler warnings like "warning: implicit conversion changes signedness: 'long' to 'unsigned long' [-Wsign-conversion]".

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

PR Review Comment: https://git.openjdk.org/jdk/pull/22848#discussion_r1895537616


More information about the hotspot-dev mailing list