<div dir="ltr"><div>Hi,</div><div><br></div><div>I am trying to find a way to fix JDK-8297285: Shenandoah pacing causes assertion failure during VM initialization.</div><div><br></div>The scenario is during VM init if the main thread exhausts the allocation budget, then the shenandoah pacer would cause it to wait. The call to wait can hit assertion self->is_active_Java_thread() in Monitor::wait() as the main thread is not yet added to the thread list, and therefore is_active_Java_thread() returns false.<br><br>The approach I have in mind is to delay initialization of ShenandoahPacer until the main thread is considered an active Java thread. But there is no hook to capture that event in the GC. The closest I found is `CollectedHeap::post_initialize()`. The comments for `CollectedHeap::post_initialize()` indicate this <i>may</i> be the right place to initialize the ShenandoahPacer:<br><br>```<br>  // In many heaps, there will be a need to perform some initialization activities<br>  // after the Universe is fully formed, but before general heap allocation is allowed.<br>  // This is the correct place to place such initialization methods.<br>  virtual void post_initialize();<br>```<br><br>However, there are still some VM init activities between the call to CollectedHeap::post_initialize() in universe_post_init and the call to Threads::add(main_thread) in Threads::create_vm(). So initializing in CollectedHeap::post_initialize() can still break if enough heap allocations happen during those activities.<br>I am wondering if there is a better place to initialize the ShenandoahPacer, or another approach to fix this situation.<div>Here is the current set of changes [0] that initialize ShenandoahPacer in  CollectedHeap::post_initialize().</div><div><div><br></div><div>[0] <a href="https://github.com/openjdk/jdk/compare/master...ashu-mehra:jdk:JDK-8297285">https://github.com/openjdk/jdk/compare/master...ashu-mehra:jdk:JDK-8297285</a></div><div><br></div><div>Thanks,<br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Ashutosh Mehra</div></div></div></div></div></div>