RFR: 8256828: ostream::print_cr() truncates buffer in copy-through case

David Holmes dholmes at openjdk.org
Mon Jun 3 07:17:02 UTC 2024


On Mon, 3 Jun 2024 06:36:50 GMT, Thomas Stuefe <stuefe 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
>
> 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?

Right "nominally" is indicating that it basically operates one way but there are exceptions as outlined in the second paragraph.

"idiomatically" means we are applying a specific coding idiom aka pattern - in this case secure programming says you never pass a non-constant string to a printf-like function, but instead pass "%s" and supply the actual string as the argument. So when we encounter that idiom will handle it specially.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/19512#discussion_r1623889256


More information about the hotspot-dev mailing list