RFR: 8354433: Assert in AbstractRBTree::visit_range_in_order(const K& from, const K& to, F f) is wrong [v2]

Casper Norrbin cnorrbin at openjdk.org
Fri Apr 25 14:25:25 UTC 2025


> There was an assert in `AbstractRBTree::visit_range_in_order` that could incorrectly trigger when:
> - The range contains no nodes, **but**
> - Nodes exist **outside** that range.
> 
> The assert checked `from <= to` indirectly via `from <= start <= to`, but `start` could be valid outside that range.
> 
> To fix this, I added the ability to supply a direct key comparison for intrusive trees to the `COMPARATOR` template. This already existed in the non-intrusive RBTree, and works the same as the other extra `cmp` function.
> 
> Additionally, I found another wrong assert in `replace_at_cursor` that is also fixed here.

Casper Norrbin has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains three additional commits since the last revision:

 - johan feedback
 - Merge branch 'master' into rbtree-assert-fix
 - assert fix with key comparator for intrusive trees

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/24658/files
  - new: https://git.openjdk.org/jdk/pull/24658/files/a9078b0c..3748e564

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

  Stats: 206487 lines in 826 files changed: 33076 ins; 170949 del; 2462 mod
  Patch: https://git.openjdk.org/jdk/pull/24658.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/24658/head:pull/24658

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


More information about the hotspot-runtime-dev mailing list