8241319: WB_GetCodeBlob doesn't have ResourceMark

Leonid Mesnik leonid.mesnik at oracle.com
Thu Mar 19 21:22:42 UTC 2020


Hi

On 3/19/20 12:25 PM, Igor Ignatyev wrote:
> Hi Leonid,
>
> wouldn't it be better to add ResourceMark to codeBlob2objectArray?

I don't know if there are any rules where to add mark for such cases. If 
you feel it is safer to better it directly to codeBlob2objectArray it is 
also ok for me. See patch (verified that crash don't happen)


diff -r 0daa6b52ba56 src/hotspot/share/prims/whitebox.cpp
--- a/src/hotspot/share/prims/whitebox.cpp      Tue Mar 17 14:13:52 2020 +0000
+++ b/src/hotspot/share/prims/whitebox.cpp      Thu Mar 19 13:22:35 2020 -0700
@@ -1513,6 +1513,7 @@
  };
  
  static jobjectArray codeBlob2objectArray(JavaThread* thread, JNIEnv* env, CodeBlobStub* cb) {
+  ResourceMark rm;
    jclass clazz = env->FindClass(vmSymbols::java_lang_Object()->as_C_string());
    CHECK_JNI_EXCEPTION_(env, NULL);
    jobjectArray result = env->NewObjectArray(4, clazz, NULL);


Leonid
>
> -- Igor
>
>> On Mar 19, 2020, at 12:14 PM, Leonid Mesnik <leonid.mesnik at oracle.com> wrote:
>>
>> Hi
>>
>> Could you please review following trivial fix which add ResourceMark in WB_GetCodeBlob. I verified that all other functions which call codeBlob2objectArray have ResourceMark already.
>>
>> The failure is not reproduced by regular testing. I hit it while running tests in virtual threads for project loom. See hs_err stack in jira issue.
>>
>>
>> bug: https://bugs.openjdk.java.net/browse/JDK-8241319
>>
>> diff:
>>
>> diff --git a/src/hotspot/share/prims/whitebox.cpp b/src/hotspot/share/prims/whitebox.cpp
>> index f8669d34a6..e389e6649d 100644
>> --- a/src/hotspot/share/prims/whitebox.cpp
>> +++ b/src/hotspot/share/prims/whitebox.cpp
>> @@ -1632,6 +1632,7 @@ WB_ENTRY(jint, WB_GetCompilationActivityMode(JNIEnv* env, jobject o))
>>   WB_END
>>
>>   WB_ENTRY(jobjectArray, WB_GetCodeBlob(JNIEnv* env, jobject o, jlong addr))
>> +  ResourceMark rm(THREAD);
>>     if (addr == 0) {
>>       THROW_MSG_NULL(vmSymbols::java_lang_NullPointerException(),
>>         "WB_GetCodeBlob: addr is null");
>>


More information about the hotspot-compiler-dev mailing list