Crash with TraceClassLoading

Markus Gronlund markus.gronlund at oracle.com
Wed Jan 8 01:49:42 PST 2014


Looks good.

/Markus

-----Original Message-----
From: David Holmes 
Sent: den 8 januari 2014 07:34
To: Staffan Larsen
Cc: hotspot-runtime-dev at openjdk.java.net
Subject: Re: Crash with TraceClassLoading



On 8/01/2014 4:28 PM, Staffan Larsen wrote:
>
> On 8 jan 2014, at 06:11, David Holmes <david.holmes at oracle.com 
> <mailto:david.holmes at oracle.com>> wrote:
>
>> On 7/01/2014 9:46 PM, Staffan Larsen wrote:
>>> This looks good to me. I can sponsor the fix once we have second review.
>>>
>>> It's unfortunate that our current test infrastructure does not allow 
>>> us to write tests with native code.
>>>
>>> /Staffan
>>>
>>>
>>> On 19 dec 2013, at 21:01, Jeremy Manson <jeremymanson at google.com 
>>> <mailto:jeremymanson at google.com>> wrote:
>>>
>>>> Now that 9 is underway, presumably we can start feeding back fixes 
>>>> again.
>>>>
>>>> This one's a bit obscure.  TraceClassLoading expects there to be a
>>>> (Java) caller when you load a class with the bootstrap class loader.
>>>>  However, there are ways of loading a class that don't involve 
>>>> having a Java caller.  For example, you can do so from a JVMTI hook.
>>>>  A reproduction is attached, and here's a patch:
>>>>
>>>> diff --git a/src/share/vm/classfile/classFileParser.cpp
>>>> b/src/share/vm/classfile/classFileParser.cpp
>>>> --- a/src/share/vm/classfile/classFileParser.cpp
>>>> +++ b/src/share/vm/classfile/classFileParser.cpp
>>>> @@ -4098,8 +4098,12 @@
>>>>         tty->print("[Loaded %s from %s]\n", this_klass->external_name(),
>>>>                    cfs->source());
>>>>       } else if (class_loader.is_null()) {
>>>> -        if (THREAD->is_Java_thread()) {
>>>> -          Klass* caller =
>>>> ((JavaThread*)THREAD)->security_get_caller_class(1);
>>>> +        Klass* caller =
>>>> +            THREAD->is_Java_thread()
>>>> +                ? ((JavaThread*)THREAD)->security_get_caller_class(1)
>>>> +                : NULL;
>>>> +        // caller can be NULL, for example, during a JVMTI VM_Init hook
>>>> +        if (caller != NULL) {
>>>>           tty->print("[Loaded %s by instance of %s]\n",
>>>>                      this_klass->external_name(),
>>>>                      InstanceKlass::cast(caller)->external_name());
>>
>> Shouldn't we have an "else" there to say "loaded %s via native 
>> mechanism" or something like that?
>
> I think the next line (not shown in the diff above) is the "else" you 
> are looking for.

Ah! Thanks. :)

Reviewed.

David

> /Staffan
>
>>
>> Thanks,
>> David
>>
>>
>>>> Jeremy
>>>> <Makefile><tcl.cc <http://tcl.cc/>>
>


More information about the hotspot-runtime-dev mailing list