RFR: 8256256: UL should not use heap allocation for output string [v4]

David Holmes dholmes at openjdk.java.net
Tue Dec 1 04:49:59 UTC 2020


On Thu, 19 Nov 2020 19:27:20 GMT, Yumin Qi <minqi at openjdk.org> wrote:

>> Hi, Please review
>>   Unified Logging uses 512 bytes buffer on stack for printing out message, above that will allocate heap for extra space needed. This may potentially may cause a circulation when we log the heap allocation and the log message is over 512. The max logging buffer size now is increased to 4096 and above that, output will be truncated.
>> 
>> Tests: tier1,tier4
>
> Yumin Qi has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Fix Copyright year

Changes requested by dholmes (Reviewer).

src/hotspot/share/logging/logTagSet.cpp line 131:

> 129:     log(level, buf);
> 130:   } else {
> 131:     // Buffer too small, allocate a large enough buffer by using of malloc/free to avoid circularity.

s/by using of/using/

src/hotspot/share/logging/logTagSet.cpp line 139:

> 137:       log(level, newbuf);
> 138:       ::free(newbuf);
> 139:     } else {

If we failed to allocate newbuf the existing buf is already filled with everything we need. Can't we just overwrite the last part with the "truncated" message rather than re-doing the whole thing?

-------------

PR: https://git.openjdk.java.net/jdk/pull/1246


More information about the hotspot-runtime-dev mailing list