JDK-8278389 : SuspendibleThreadSet::_suspend_all should be volatile/atomic
  • Type: Bug
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 11,17,18
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2021-12-08
  • Updated: 2022-08-08
  • Resolved: 2021-12-16
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 17 JDK 18 JDK 19
17.0.3Fixed 18 b29Fixed 19Fixed
Related Reports
Relates :  
Description
SuspendibleThreadSet::should_yield() just returns the value of the _suspend_all flag, which is a simple static variable. That variable is set under a lock, but possibly read concurrently by other threads without any locking.

[For considerations of backporting] This is *probably* effectively harmless, as any loops involving should_yield checks probably won't have the check hoisted out of the loop due to sufficiently opaque loop bodies.

Comments
Fix Request (17u) This fortifies GC code in face of concurrent suspends. G1, Shenandoah, Z (?) might be affected by native compilers hoisting unprotected reads out of the loop. Applies cleanly.
18-01-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk17u-dev/pull/54 Date: 2022-01-04 14:00:26 +0000
04-01-2022

I still think it would be safer to backport, rather than hope all uses of should_yield are safe. I think it might affect all GCs, since should_yield is used from shared strdedup code (although it is hard to proactively come up with a scenario where how it would fail).
20-12-2021

Changeset: aec1b039 Author: Thomas Schatzl <tschatzl@openjdk.org> Date: 2021-12-16 12:29:57 +0000 URL: https://git.openjdk.java.net/jdk18/commit/aec1b039b35b73db17c943cdd86949a92e64fcb6
16-12-2021