RFR: 8332818: ubsan: archiveHeapLoader.cpp:70:27: runtime error: applying non-zero offset 18446744073707454464 to null pointer
Thomas Stuefe
stuefe at openjdk.org
Thu Jun 13 05:00:16 UTC 2024
On Thu, 13 Jun 2024 02:46:59 GMT, David Holmes <dholmes at openjdk.org> wrote:
> > Adding to NULL is undefined,
>
> Hmm okay. So really our `address` abstraction should be dealing with intptr_t or uintptr_t to perform any arithmetic and then cast the result back to an actual pointer type when done?
Well, not sure.
C99:
`5 An integer may be converted to any pointer type. Except as previously specified, the result is implementation-defined, might not be correctly aligned, might not point to an entity of the referenced type, and might be a trap representation. 56)`
The one platform I talked about (IBM AS/400 in native mode) did the latter. Casting integer to pointer resulted in an invalid pointer that would trap on dereferencing.
Personally, I think hunting UB is sorting out the chaff to find the useful bits. Pity that we cannot selectivly switch off UB cases with the compiler, and have to decorate code instead.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/19597#issuecomment-2164375613
More information about the hotspot-runtime-dev
mailing list