RFR: 8035648: Don't use Handle in java_lang_String::print

David Holmes david.holmes at oracle.com
Mon Feb 24 18:37:39 PST 2014


On 24/02/2014 11:08 PM, Stefan Karlsson wrote:
>
> On 2014-02-24 13:11, David Holmes wrote:
>> Stefan,
>>
>> On 24/02/2014 7:44 PM, Stefan Karlsson wrote:
>>> Hi all,
>>>
>>> Please, review this change to let java_lang_String::print take a raw
>>> String oop instead of a Handle to a String oop. This change makes
>>> java_lang_String::print callable from code that has no HandleMark setup.
>>
>> I don't think you can do that. The printing code can encounter a
>> safepoint and block thus allowing a raw oop to be exposed over a
>> potential GC point.
>
> If that's the case, then the code was already buggy before my change:
>
> 1) Before the patch the first thing we did was to convert the Handle to
> a raw oop. IMHO, there's no difference in safepoint safeness here.
> void java_lang_String::print(Handle java_string, outputStream* st) {
>    oop          obj    = java_string();
>
> 2) the 'value' object would also be susceptible to this kind of bug:
>      for (int index = 0; index < length; index++) {
>        st->print("%c", value->char_at(index + offset));
>      }
>
> Do you know of an implementation of outputStream that allows us to block
> for a safepoint? If not, would you be fine with the change if I add a
> No_Safepoint_Verifier?

Sorry for the noise - I was misremembering how outputstream locking was 
performed.

David
-----

> thanks,
> StefanK
>
>>
>>
>> David
>>
>>> E.g. when calling from a debugger.
>>>
>>> Webrev:
>>> http://cr.openjdk.java.net/~stefank/8035648/webrev.00/
>>>
>>> RFE:
>>> https://bugs.openjdk.java.net/browse/JDK-8035648
>>>
>>> thanks,
>>> StefanK
>


More information about the hotspot-dev mailing list