RFR: 8256828: ostream::print_cr() truncates buffer in copy-through case
Thomas Stuefe
stuefe at openjdk.org
Mon Jun 3 06:41:02 UTC 2024
On Sun, 2 Jun 2024 22:05:40 GMT, David Holmes <dholmes at openjdk.org> wrote:
> Clarifies the behaviour of this function in regards to truncation when adding a CR. Ensures a truncation warning is always issued.
>
> Adds unit testing for the specialized cases.
>
> See JBS for discussion of other suggestions.
>
> Testing: - tiers 1-4
>
> Thanks
So, just to clarify, this is a behavioral change, right?
Where before we would not truncate raw strings, now we do, since result_len is used to determine how many bytes we will write to the output sink.
src/hotspot/share/utilities/ostream.cpp line 109:
> 107: result_len = buflen - 1;
> 108: }
> 109: } else if (format[0] == '%' && format[1] == 's' && format[2] == '\0') {
nit, preexisting: why not just `strncmp(format, "%s", 3) == 0`?
src/hotspot/share/utilities/ostream.hpp line 74:
> 72: // of the returned string.
> 73: //
> 74: // In a debug build, if truncation occurs a VM warning is issued.
I had to think a bit (I am not a native English speaker) about what the "Nominally" means, but I think it is supposed to contrast the second paragraph? As in "Normally we do that, but in the case of ... we do... ?". Same for "idiomatically" - what does that signify?
-------------
PR Review: https://git.openjdk.org/jdk/pull/19512#pullrequestreview-2092883626
PR Review Comment: https://git.openjdk.org/jdk/pull/19512#discussion_r1623841035
PR Review Comment: https://git.openjdk.org/jdk/pull/19512#discussion_r1623850806
More information about the hotspot-dev
mailing list