RFR: 8341178: TypeRawPtr::add_offset may be "miscompiled" due to UB [v3]

Kim Barrett kbarrett at openjdk.org
Wed Oct 9 14:57:37 UTC 2024


> Please review this change to TypeRawPtr::add_offset to prevent a compiler from
> inferring things based on prior pointer arithmetic not invoking UB.  As noted in
> the bug report, clang is actually doing this.
> 
> To accomplish this, changed to integral arithmetic.  Also added over/underflow
> checks.
> 
> Also made a couple of minor touchups.  Replaced an implicit conversion to bool
> with an explicit compare to nullptr (per style guide).  Removed a no longer
> needed dummy return after a (now) noreturn function.
> 
> Testing: mach5 tier1-7
> That testing was with calls to "fatal" for the over/underflow cases and the
> sum==0 case.  There were no hits.  I'm not sure how to construct a test that
> would hit those.

Kim Barrett has updated the pull request incrementally with one additional commit since the last revision:

  remove unreachable TypePtr::Null case

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/21324/files
  - new: https://git.openjdk.org/jdk/pull/21324/files/cc1f2ac8..c3dc62e7

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=21324&range=02
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=21324&range=01-02

  Stats: 2 lines in 1 file changed: 0 ins; 2 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/21324.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/21324/head:pull/21324

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


More information about the hotspot-compiler-dev mailing list