RFR: 8259070: Add jcmd option to dump CDS [v4]
Yumin Qi
minqi at openjdk.java.net
Thu Mar 18 03:34:53 UTC 2021
On Sat, 27 Feb 2021 05:12:25 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
>> src/hotspot/share/memory/metaspaceShared.cpp line 783:
>>
>>> 781: char* start = buffer + strlen(buffer);
>>> 782: snprintf(start, buff_len, "%s ", arg);
>>> 783: }
>>
>> Maybe move the above function to the StringUtils class under share/utilities?
>> Use `os::snprintf()` instead of `snprintf()`?
>
> The calculation is also wrong, this would overflow. You need:
> char* start = buffer + strlen(buffer);
> snprintf(start, buff_len - (start - buffer), "%s ", arg);
> - and maybe add an assert that strlen(buf) < bufflen.
> - and as Ioi wrote, I'd use either one of os::snprintf or jio_snprintf since both guarantee zero termination on truncation.
> - or, just use strncat()
The new solution is using CDS.java to do the work.
-------------
PR: https://git.openjdk.java.net/jdk/pull/2737
More information about the serviceability-dev
mailing list