RFR: 8347707: Standardise the use of os::snprintf and os::snprintf_checked

David Holmes dholmes at openjdk.org
Thu Aug 21 06:25:53 UTC 2025


On Thu, 21 Aug 2025 06:21:00 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> src/hotspot/share/gc/shared/satbMarkQueue.cpp line 324:
>> 
>>> 322: 
>>> 323:     virtual void do_thread(Thread* t) {
>>> 324:       os::snprintf_checked(_buffer, SATB_PRINTER_BUFFER_SIZE, "Thread: %s", t->name());
>> 
>> Suggestion:
>> 
>>       (void) os::snprintf(_buffer, SATB_PRINTER_BUFFER_SIZE, "Thread: %s", t->name());
>> 
>> Can this be a JavaThread with an arbitrarily long name()?
>
> Yes it could - thanks. It is likely enough that we could hit this during testing that asserting if it happens is not really useful. Long Java thread names are not necessarily errors to be fixed.

In addition, if we were to hit such a name we are not likely to increase the buffer size just for this extreme case.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26849#discussion_r2289973406


More information about the hotspot-dev mailing list