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

Martin Doerr mdoerr at openjdk.org
Fri May 3 14:06:16 UTC 2024


`index_oop_from_field_offset_long` is sometimes used to access an absolute address by using `p == nullptr`. Unfortunately, `nullptr + byte_offset` implies undefined behavior and should better get fixed. UBSan complains about it (see JBS issue).
A possible solution is to replace pointer arithmetic by integer arithmetic. We can use unsigned because `assert_field_offset_sane` checks that `byte_offset >= 0`.

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

Commit messages:
 - 8331626: unsafe.cpp:162:38: runtime error in index_oop_from_field_offset_long - applying non-zero offset 4563897424 to null pointer

Changes: https://git.openjdk.org/jdk/pull/19087/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=19087&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8331626
  Stats: 7 lines in 1 file changed: 0 ins; 4 del; 3 mod
  Patch: https://git.openjdk.org/jdk/pull/19087.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/19087/head:pull/19087

PR: https://git.openjdk.org/jdk/pull/19087


More information about the hotspot-dev mailing list