Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ddprof-lib/src/main/cpp/profiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,10 @@ Error Profiler::checkJvmCapabilities() {
return Error("Could not find VMThread bridge. Unsupported JVM?");
}

if (VM::isUseAdaptiveGCBoundarySet()) {
return Error("The user has explicitly set -XX:+UseAdaptiveGCBoundary so the profiler has been disabled to avoid the risk of crashing.");
}

if (_dlopen_entry == NULL) {
CodeCache* lib = findJvmLibrary("libj9prt");
if (lib == NULL || (_dlopen_entry = lib->findGlobalOffsetEntry((void*)dlopen)) == NULL) {
Expand Down
8 changes: 8 additions & 0 deletions ddprof-lib/src/main/cpp/vmEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ bool VM::_hotspot = false;
bool VM::_zing = false;
bool VM::_can_sample_objects = false;
bool VM::_can_intercept_binding = false;
bool VM::_is_adaptive_gc_boundary_flag_set = false;
jobject VM::_global_system_classloader = nullptr;
jobject VM::_global_platform_classloader = nullptr;

Expand Down Expand Up @@ -291,6 +292,13 @@ bool VM::init(JavaVM* vm, bool attach) {
}
}

// if the user sets -XX:+UseAdaptiveGCBoundary we will just disable the profiler to avoid the risk of crashing
// flag was made obsolete (inert) in 15 (see JDK-8228991) and removed in 16 (see JDK-8231560)
if (java_version() < 15) {
char* flag_addr = (char*)JVMFlag::find("UseAdaptiveGCBoundary");
_is_adaptive_gc_boundary_flag_set = flag_addr != NULL && *flag_addr == 1;
}

if (attach) {
loadAllMethodIDs(jvmti(), jni());
_jvmti->GenerateEvents(JVMTI_EVENT_DYNAMIC_CODE_GENERATED);
Expand Down
5 changes: 5 additions & 0 deletions ddprof-lib/src/main/cpp/vmEntry.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class VM {
static bool _zing;
static bool _can_sample_objects;
static bool _can_intercept_binding;
static bool _is_adaptive_gc_boundary_flag_set;

static jobject _global_system_classloader;
static jobject _global_platform_classloader;
Expand Down Expand Up @@ -170,6 +171,10 @@ class VM {
return _zing;
}

static bool isUseAdaptiveGCBoundarySet() {
return _is_adaptive_gc_boundary_flag_set;
}

static bool isSystemClassLoader(JNIEnv* jni, jobject& cl);

static void JNICALL VMInit(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread);
Expand Down