RFR: 8368124: Show useful thread names in ASAN reports [v4]

Thomas Stuefe stuefe at openjdk.org
Wed Sep 24 05:48:16 UTC 2025


On Wed, 24 Sep 2025 01:34:50 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> Thomas Stuefe has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   review feedback
>
> src/hotspot/os/linux/os_linux.cpp line 4863:
> 
>> 4861:   // for thread names is to be both longer than 15 chars and have a trailing number
>> 4862:   // ("DispatcherWorkerThread21", "C2 CompilerThread#54" etc), we truncate "smartly"
>> 4863:   // by attempting to preserve the trailing number in the name if there is one
> 
> This "smart" aspect is no longer present right? If the name ends in a number the number will be presented (or at least a few digits) simply because it comes at the end.
> 
> There will always be cases where the truncation method results in a "worse" name than an alternate truncation method would - hence why I do not think it is worth over engineering this. For example if the name is `ForkJoinPool-5-worker-21` you will lose important information no matter what.

This series of ASAN issues came from a real customer case we are working on, and in that one having the trailing number preserved was really useful. And certainly, something like "C2 Com..hread4" is more useful than "C2 CompilerThre"?

> 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.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27395#discussion_r2374478129
PR Review Comment: https://git.openjdk.org/jdk/pull/27395#discussion_r2374473914


More information about the hotspot-dev mailing list