RFR: 8367646: [GenShen] Control thread may overwrite gc cancellation cause set by mutator [v2]

William Kemper wkemper at openjdk.org
Thu Oct 9 18:23:17 UTC 2025


> I believe the following events could lead to this assertion failure:
> 1. Control thread reads the heap's gc cancellation cause as `shenandoah_concurrent_gc` 
> 2. Mutator thread has an allocation failure and sets the heap's gc cancellation cause to `shenandoah_alloc_failure`
> 3. Control thread uses stale value from `1` and decides to unconditionally clear the cancellation cause
> 4. Mutator thread assert that gc is still cancelled
> 
> The proposed fix here has the control thread use a CAS operation to only clear the gc if the existing value is `shenandoah_concurrent_gc`. This will stop the control thread from erroneously changing the value if a mutator has already set it to `shenandoah_alloc_failure`. A mutator thread may still have an allocation failure after the control thread has cleared the cancellation, but this is normal and expected.

William Kemper has updated the pull request incrementally with one additional commit since the last revision:

  Fix cancellation time management, simplify normal cancellation API

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/27662/files
  - new: https://git.openjdk.org/jdk/pull/27662/files/d9697d83..b3a96523

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

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

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


More information about the shenandoah-dev mailing list