Crashes in JvmtiExport::post_compiled_method_load were found in JDK8 of our production environment after one day when users started to receive the JVMTI COMPILED_METHOD_LOAD event.
This issue behaved similarly to JDK-8173361.
After debugging, ServiceThread::nmethods_do backported by JDK-8173361 is not called.
JavaThread::nmethods_do should be a virtual function just like 11u or later, otherwise, the following routine cannot call the correct nmethods_do for ServiceThread.
ALL_JAVA_THREADS(p) {
p->nmethods_do(cf);
}
Because this issue cannot be easily reproduced, manually adding some delay on purpose in ServiceThread::service_thread_entry to keep more events pending in JvmtiDeferredEventQueue could help reproduce this issue.
After the fix, various crashes were gone.