8297285: Shenandoah pacing causes assertion failure during VM initialization

Reviewed-by: rkennke, phh
This commit is contained in:
Ashutosh Mehra 2022-12-02 14:22:52 +00:00 committed by Paul Hohensee
parent df072556a5
commit 415cfd2e28

View File

@ -29,6 +29,7 @@
#include "gc/shenandoah/shenandoahPacer.hpp"
#include "gc/shenandoah/shenandoahPhaseTimings.hpp"
#include "runtime/atomic.hpp"
#include "runtime/javaThread.inline.hpp"
#include "runtime/mutexLocker.hpp"
#include "runtime/threadSMR.hpp"
@ -241,7 +242,13 @@ void ShenandoahPacer::pace_for_alloc(size_t words) {
// Threads that are attaching should not block at all: they are not
// fully initialized yet. Blocking them would be awkward.
// This is probably the path that allocates the thread oop itself.
if (JavaThread::current()->is_attaching_via_jni()) {
//
// Thread which is not an active Java thread should also not block.
// This can happen during VM init when main thread is still not an
// active Java thread.
JavaThread* current = JavaThread::current();
if (current->is_attaching_via_jni() ||
!current->is_active_Java_thread()) {
return;
}