RFR: 8347426: Invalid value used for enum Cell in iTypeFlow::StateVector::meet_exception [v2]

Marc Chevalier duke at openjdk.org
Thu Feb 27 08:28:57 UTC 2025


> As guess on the JBS ticket, we have a UB when `_outer->max_locals() == 0`, because then we try to do `(Cell)(-1)` which is out of range since Cell's range is [0, `INT_MAX`].
> 
> The obvious fix that is
> 
> Cell limit = local(_outer->max_locals());
> for (Cell c = start_cell(); c < limit; c = next_cell(c)) {
> 
> since `local` asserts its argument to be in [0, `outer->max_locals()`). Of course
> 
> Cell limit = (Cell)(_outer->max_locals());
> 
> would work, but it seems to break (the very light) abstraction.
> 
> I've also added an assert to transform the UB into a clear failure.
> 
> This fix makes the UB warning go away on Mac with arm64.
> 
> Thanks,
> Marc

Marc Chevalier has updated the pull request incrementally with one additional commit since the last revision:

  Introduce local_limit_cell

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/23772/files
  - new: https://git.openjdk.org/jdk/pull/23772/files/e2ba08fa..ff7461b5

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

  Stats: 13 lines in 2 files changed: 2 ins; 2 del; 9 mod
  Patch: https://git.openjdk.org/jdk/pull/23772.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/23772/head:pull/23772

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


More information about the hotspot-compiler-dev mailing list