RFR(S): 8191229: serviceability/jvmti/GetOwnedMonitorInfo/GetOwnedMonitorInfoTest.java fails with NoClassDefFoundError
Chris Plummer
chris.plummer at oracle.com
Thu Dec 7 19:19:00 UTC 2017
On 12/7/17 10:51 AM, Chris Plummer wrote:
> On 12/7/17 9:27 AM, Chris Plummer wrote:
>> On 12/7/17 8:49 AM, Chris Plummer wrote:
>>> On 12/7/17 2:41 AM, David Holmes wrote:
>>>> Hi Chris,
>>>>
>>>> On 7/12/2017 5:44 PM, Chris Plummer wrote:
>>>>> New webrev:
>>>>>
>>>>> https://bugs.openjdk.java.net/browse/JDK-8191229
>>>>> http://cr.openjdk.java.net/~cjplummer/8191229/webrev.01/
>>>>>
>>>>> testClass now initialized from JNI_OnLoad(), and use memset to
>>>>> clear callbacks. Also updated to use JVMTI_VERSION_9 when calling
>>>>> GetEnv().
>>>>
>>>> � 71�������� // JNI_OnLoad has not been called yet, so can't
>>>> possibly be an instance of TEST_CLASS.
>>>>
>>>> You can't be executing this method before JNI_OnLoad has executed.
>>>> If JNI_Onload has executed then you can't execute this method and
>>>> find NULL as that means JNI_Onload failed and hence library loading
>>>> fails and so you can't be executing this method. So this method
>>>> reduces to a simple instanceof check, which can go straight into
>>>> the calling method.
>>> That's what I thought, but it was crashing because testClass was
>>> NULL. I think Agent_OnLoad() is being called before JNI_OnLoad. I'll
>>> add traces and see for sure.
>> Printfs confirm that (at least in the one run I just did)
>> Agent_OnLoad() was called before JNI_OnLoad(). However, I'm not
>> certain that is always the case, because before I put the NULL check
>> in, it only crashed 12 out of 50 times. 2 of those were on a
>> linux-x64 product build and the rest were on the macosx debug build.
>> Debug builds on Windows, solaris, and linux were fine. I'm not
>> certain of the call environment for either of these functions, but I
>> can at least see that Agent_OnLoad() is called on a different thread
>> than JNI_OnLoad(), which is called on the test's main thread. So a
>> race is seems possible.
> I think Agent_OnLoad() is always called before JNI_OnLoad(), but the
> reason is it only sometimes crashes without the NULL check is the same
> as the reason this bug exists in the first place. It requires an
> unexpected contended monitor callback, and that doesn't always happen
> before JNI_OnLoad is called.
>
> I think this might be another good reason to move the FindClass code
> to Agent_Initialize(), which is called by Agent_Onload(). It will
> guarantee that testClass is set before we setup the contended monitor
> callbacks.
Well, that won't work. GetEnv() for a JNIEnv returns JNI_EDETACHED when
called from Agent_OnLoad(). So I think that means I'm sticking with the
last webrev and leaving the NULL check of testClass in place.
Chris
>
> Chris
>>
>> Chris
>>>
>>> Chris
>>>>
>>>> �183���� if (testClass == NULL) {
>>>>
>>>> That can just be "else {" - but as I said it can't be NULL anyway.
>>>>
>>>> Thanks,
>>>> David
>>>>
>>>>> thanks,
>>>>>
>>>>> Chris
>>>
>>>
>>>
>>
>>
>
>
More information about the serviceability-dev
mailing list