RFR: 8346714: [ASAN] compressedKlass.cpp reported applying non-zero offset to null pointer [v2]
Andrew Haley
aph at openjdk.org
Sun Dec 22 17:50:40 UTC 2024
On Sat, 21 Dec 2024 10:57:21 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
> > Thanks for fixing the issue! This should work. In general, I still prefer using `uintptr_t` because `intptr_t` has undefined behavior on overflow. Probably not in this case, here.
>
> +1. Also, instead of casting manually, please use p2u (and if there is none, we should add it like we have a p2i for intptr_t).
>
> I am somewhat unenthusiastic about changes like these. We seem to add a lot of casting boilerplate to satisfy UBsan for the sake of cleanliness that only matters on special hardware that treats pointers differently from numeric.
True, but we can very effectively make the compiler and the reader happy by using `uintptr_t` for all of the arithmetic. After all, we are not using null-based compressed pointers, we are using zero-based compressed pointers, and the distinction is important. `uintptr_t` does not have null as a member, it has zero; conversely `address` does not have zero, it has null. Therefore, when we are using zero-based compressed pointers, better to to use `uintptr_t` for the arithmetic.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/22848#issuecomment-2558534965
More information about the hotspot-dev
mailing list