RFR: 8256256: UL should not use heap allocation for output string [v4]
David Holmes
dholmes at openjdk.java.net
Tue Dec 1 06:30:58 UTC 2020
On Tue, 1 Dec 2020 05:36:25 GMT, Yumin Qi <minqi at openjdk.org> wrote:
>> 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?
>
> line 124: When buf is small, buf is filled with whatever truncated string with format to get the length needed for new buffer, it does not include prefix. The new version keeps prefix and the buf ends with "..(truncated), native OOM" even if prefix already overflows buf.
Ah I missed that. But do we need to do that? If we introduce:
`char buf2[1];`
at line 123 and use that to determine the necessary additional length, then we don't need to re-start the whole process from scratch.
-------------
PR: https://git.openjdk.java.net/jdk/pull/1246
More information about the hotspot-runtime-dev
mailing list