RFR: 8368124: Show useful thread names in ASAN reports [v4]
David Holmes
dholmes at openjdk.org
Wed Sep 24 06:56:16 UTC 2025
On Wed, 24 Sep 2025 05:43:09 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
>> src/hotspot/share/utilities/stringUtils.cpp line 153:
>>
>>> 151: const int l = checked_cast<int>(strlen(s));
>>> 152: // Impose some reasonable length below which we just truncate dumbly (4 chars each for head/tail)
>>> 153: constexpr int smart_truncation_threshold = dots + (4 * 2);
>>
>> I'm really not understanding the "smart-threshold" here; nor does this seem worthy of being a utility function.
>
> The smart-threshold is just a threshold to switch to plain truncation. E.g. if the output buffer were just four characters, the resulting name would be "C..3".
>
> I disagree about making this a utility function. A function like this makes sense in a number of cases. It certainly is preferable to dumb truncation without any indication one truncated. Arguably, with longer output buffers something like "...(truncate)..." in the middle would be even more helpful.
>
> And having it a separate function allows me to test the function in gtest.
Sorry I'm still not grokking this 4 chars aspect. For whatever buffer size, if the length of the name < buffer_len we write it as-is. Otherwise we chop out the middle and replace with .. such that it fits in the buffer.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27395#discussion_r2374639723
More information about the hotspot-dev
mailing list