Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8261607: SA attach is exceeding JNI Local Refs capacity #2568

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2020, NTT DATA.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -183,6 +183,8 @@ static void fillThreadsAndLoadObjects(JNIEnv* env, jobject this_obj, struct ps_p
CHECK_EXCEPTION;
env->CallBooleanMethod(threadList, listAdd_ID, thread);
CHECK_EXCEPTION;
env->DeleteLocalRef(thread);
env->DeleteLocalRef(threadList);
}

// add load objects
@@ -205,6 +207,9 @@ static void fillThreadsAndLoadObjects(JNIEnv* env, jobject this_obj, struct ps_p
CHECK_EXCEPTION;
env->CallBooleanMethod(loadObjectList, listAdd_ID, loadObject);
CHECK_EXCEPTION;
env->DeleteLocalRef(str);
env->DeleteLocalRef(loadObject);
env->DeleteLocalRef(loadObjectList);
}
}

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -965,14 +965,17 @@ static bool wait_for_exception() {
called from Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_attach0__Ljava_lang_String_2Ljava_lang_String_2 */
static void fillLoadObjects(JNIEnv* env, jobject this_obj, struct ps_prochandle* ph) {
int n = 0, i = 0;
jobject loadObjectList;

loadObjectList = (*env)->GetObjectField(env, this_obj, loadObjectList_ID);
CHECK_EXCEPTION;

// add load objects
n = get_num_libs(ph);
for (i = 0; i < n; i++) {
uintptr_t base;
const char* name;
jobject loadObject;
jobject loadObjectList;
jstring nameString;

base = get_lib_base(ph, i);
@@ -982,10 +985,10 @@ static void fillLoadObjects(JNIEnv* env, jobject this_obj, struct ps_prochandle*
loadObject = (*env)->CallObjectMethod(env, this_obj, createLoadObject_ID,
nameString, (jlong)0, (jlong)base);
CHECK_EXCEPTION;
loadObjectList = (*env)->GetObjectField(env, this_obj, loadObjectList_ID);
CHECK_EXCEPTION;
(*env)->CallBooleanMethod(env, loadObjectList, listAdd_ID, loadObject);
CHECK_EXCEPTION;
(*env)->DeleteLocalRef(env, nameString);
(*env)->DeleteLocalRef(env, loadObject);
}
}

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -503,6 +503,7 @@ static bool addLoadObjects(JNIEnv* env, jobject obj) {
env->CallVoidMethod(obj, addLoadObject_ID, strName, (jlong) params[u].Size,
(jlong) params[u].Base);
CHECK_EXCEPTION_(false);
env->DeleteLocalRef(strName);
}

return true;
@@ -629,6 +630,7 @@ static bool addThreads(JNIEnv* env, jobject obj) {

env->CallVoidMethod(obj, setThreadIntegerRegisterSet_ID, (jlong)ptrThreadIds[t], regs);
CHECK_EXCEPTION_(false);
env->DeleteLocalRef(regs);

ULONG sysId;
COM_VERIFY_OK_(ptrIDebugSystemObjects->GetCurrentThreadSystemId(&sysId),
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -144,6 +144,9 @@ private String runCmd(List<String> commands,
System.out.println("Output: ");
System.out.println(output);

// -Xcheck:jni might be set via TEST_VM_OPTS. Make sure there are no warnings.
oa.shouldNotMatch("^WARNING: JNI local refs:.*$");
oa.shouldNotMatch("^WARNING in native method:.*$");
// This will detect most SA failures, including during the attach.
oa.shouldNotMatch("^sun.jvm.hotspot.debugger.DebuggerException:.*$");
// This will detect unexpected exceptions, like NPEs and asserts, that are caught
ProTip! Use n and p to navigate between commits in a pull request.