From 8331e63fe419e9ab796732fb01e0a68f8474045c Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 30 Sep 2020 08:58:24 +0000 Subject: [PATCH] 8253778: ShenandoahSafepoint::is_at_shenandoah_safepoint should not access VMThread state from other threads Reviewed-by: jiefu, rehn, rkennke --- src/hotspot/share/gc/shenandoah/shenandoahUtils.hpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/gc/shenandoah/shenandoahUtils.hpp b/src/hotspot/share/gc/shenandoah/shenandoahUtils.hpp index 8324c5caef8..2f4fde13641 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahUtils.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahUtils.hpp @@ -141,10 +141,17 @@ public: class ShenandoahSafepoint : public AllStatic { public: - // check if Shenandoah GC safepoint is in progress + // Check if Shenandoah GC safepoint is in progress. This is nominally + // equivalent to calling SafepointSynchronize::is_at_safepoint(), but + // it also checks the Shenandoah specifics, when it can. static inline bool is_at_shenandoah_safepoint() { if (!SafepointSynchronize::is_at_safepoint()) return false; + // This is not VM thread, cannot see what VM thread is doing, + // so pretend this is a proper Shenandoah safepoint + if (!Thread::current()->is_VM_thread()) return true; + + // Otherwise check we are at proper operation type VM_Operation* vm_op = VMThread::vm_operation(); if (vm_op == NULL) return false;