8307865: Invalid is_in_any_VTMS_transition() check in post_dynamic_code_generated_while_holding_locks

Reviewed-by: sspitsyn, cjplummer
This commit is contained in:
Leonid Mesnik 2023-05-18 23:57:10 +00:00
parent 4a6d6d5a59
commit 42948c04b9
3 changed files with 17 additions and 10 deletions

View File

@ -2592,8 +2592,6 @@ void JvmtiExport::post_dynamic_code_generated_while_holding_locks(const char* na
address code_begin, address code_end) address code_begin, address code_end)
{ {
JavaThread* thread = JavaThread::current(); JavaThread* thread = JavaThread::current();
assert(!thread->is_in_any_VTMS_transition(), "dynamic code generated events are not allowed in any VTMS transition");
// register the stub with the current dynamic code event collector // register the stub with the current dynamic code event collector
// Cannot take safepoint here so do not use state_for to get // Cannot take safepoint here so do not use state_for to get
// jvmti thread state. // jvmti thread state.

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -33,6 +33,7 @@
import java.lang.ref.Reference; import java.lang.ref.Reference;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.locks.LockSupport;
public class DynamicCodeGeneratedTest { public class DynamicCodeGeneratedTest {
static { static {
@ -49,14 +50,21 @@ public class DynamicCodeGeneratedTest {
threadChangeENM.setDaemon(true); threadChangeENM.setDaemon(true);
threadChangeENM.start(); threadChangeENM.start();
Runnable task = () -> {
String result = "string" + System.currentTimeMillis();
// Park to provoke re-mounting of virtual thread.
LockSupport.parkNanos(1);
Reference.reachabilityFence(result);
};
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
List<Thread> threads = new ArrayList(); List<Thread> threads = new ArrayList();
for (int j = 0; j < 200; j++) { for (int j = 0; j < 200; j++) {
Thread t = new Thread(() -> { threads.add(Thread.ofVirtual().unstarted(task));
String result = "string" + System.currentTimeMillis(); threads.add(Thread.ofPlatform().unstarted(task));
Reference.reachabilityFence(result); }
});
threads.add(t); for (Thread t: threads) {
t.start(); t.start();
} }
for (Thread t: threads) { for (Thread t: threads) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,6 +23,7 @@
#include <string.h> #include <string.h>
#include <jvmti.h> #include <jvmti.h>
#include "jvmti_common.h"
static jvmtiEnv* jvmti = NULL; static jvmtiEnv* jvmti = NULL;
@ -43,7 +44,7 @@ void JNICALL Java_DynamicCodeGeneratedTest_changeEventNotificationMode(JNIEnv* j
#endif #endif
void JNICALL DynamicCodeGenerated(jvmtiEnv* jvmti, const char* name, const void* address, jint length) { void JNICALL DynamicCodeGenerated(jvmtiEnv* jvmti, const char* name, const void* address, jint length) {
LOG("Event: %s\n", name);
} }
JNIEXPORT jint JNICALL JNIEXPORT jint JNICALL