RFR: 8373116: Genshen: arraycopy_work should be done unconditionally by arraycopy_marking if the array is in an old region

Xiaolong Peng xpeng at openjdk.org
Fri Dec 5 00:27:20 UTC 2025


Chasing the root cause of JDK-8372498, I have narrowed down root cause to the commit https://github.com/openjdk/jdk/commit/f8cf9ca69cfef286c80559bfe1d147b6303d10d2

It is caused by the behavior change from follow code:

Original:

  if (ShenandoahSATBBarrier) {
    T* array = dst;
    HeapWord* array_addr = reinterpret_cast<HeapWord*>(array);
    ShenandoahHeapRegion* r = _heap->heap_region_containing(array_addr);
    if (is_old_marking) {
      // Generational, old marking
      assert(_heap->mode()->is_generational(), "Invariant");
      if (r->is_old() && (array_addr < _heap->marking_context()->top_at_mark_start(r))) {
        arraycopy_work<T, false, false, true>(array, count);
      }
    } else if (_heap->mode()->is_generational()) {
      // Generational, young marking
      if (r->is_old() || (array_addr < _heap->marking_context()->top_at_mark_start(r))) {
        arraycopy_work<T, false, false, true>(array, count);
      }
    } else if (array_addr < _heap->marking_context()->top_at_mark_start(r)) {
      // Non-generational, marking
      arraycopy_work<T, false, false, true>(array, count);
    }
  }

New:

  if (ShenandoahSATBBarrier) {
    if (!_heap->marking_context()->allocated_after_mark_start(reinterpret_cast<HeapWord*>(dst))) {
      arraycopy_work<T, false, false, true>(dst, count);
    }
  }



With the new STAB barrier code for arraycopy_marking, if is it young GC and the array is in old region, but array is above TAMS, arraycopy_work won't be applied anymore, so we may have missed some pointers in SATB in such case.

### Test
- [x] hotspot_gc_shenandoah
- [ ] repeat gc/TestAllocHumongousFragment.java#generational and sure it won't crash with the fix
- [ ] GHA

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

Commit messages:
 - Reorder the code
 - Assert only when the obj been pointed to is in young
 - Add assert to check card table to sure card table is correct
 - Merge branch 'openjdk:master' into JDK-8372498
 - arraycopy_work should be done unconditionally if the array is in an old region

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

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


More information about the shenandoah-dev mailing list