RFR[9u-dev]: 8151442: jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
Robbin Ehn
robbin.ehn at oracle.com
Mon Mar 21 08:53:52 UTC 2016
Hi, sorry for the unnecessary review,
My mail-client spitted the mail thread into two different folders.
/Robbin
On 03/21/2016 09:18 AM, Robbin Ehn wrote:
> Hi Cheleswer,
>
> On 03/18/2016 08:54 AM, Cheleswer Sahu wrote:
>> Hi,
>>
>> Please review the code changes for
>> https://bugs.openjdk.java.net/browse/JDK-8151442.
>>
>> Webrev Link: http://cr.openjdk.java.net/~csahu/8151442/
>>
>> Bug Brief:
>>
>> In jstack thread dumps , thread name greater than 1996 characters
>> doesn’t close quotation marks properly.
>>
>> Problem Identified:
>>
>> Jstack is using below code to print thread name
>>
>> src/share/vm/runtime/thread.cpp
>>
>> void JavaThread::print_on(outputStream *st) const {
>>
>> st->print("\"%s\" ", get_thread_name());
>>
>> Here “st->print()” internally uses max buffer length as O_BUFLEN (2000).
>>
>> void outputStream::do_vsnprintf_and_write_with_automatic_buffer(const
>> char* format, va_list ap, bool add_cr) {
>>
>> char buffer[O_BUFLEN];
>>
>> do_vsnprintf_and_write_with_automatic_buffer() finally calls
>> “vsnprintf()” which truncates the anything greater than the max
>> size(2000). In this case thread’s name(> 1996) along with quotation
>> marks (2)
>>
>> plus one terminating character exceeds the max buffer size (2000),
>> therefore the closing quotation marks gets truncated.
>>
>> Solution:
>>
>> Split the “st->print("\"%s\" ", get_thread_name())” in two statements
>>
>> 1.st->print("\"%s", get_thread_name());
>>
>> 2.st->print("\" “);
>
> This looks good, thanks for fixing.
>
> /Robbin (not a reviewer)
>
> (I must admit I'm very curious why anyone would have a thread name that
> long)
>
>>
>> This will ensure presence of closing quotation mark always.
>>
>> Regards,
>>
>> Cheleswer
>>
More information about the serviceability-dev
mailing list