RFR: 8368124: Show useful thread names in ASAN reports [v2]
Thomas Stuefe
stuefe at openjdk.org
Tue Sep 23 05:49:17 UTC 2025
On Mon, 22 Sep 2025 06:15:20 GMT, David Holmes <dholmes at openjdk.org> wrote:
> I see now in JBS that you say you don't know why what we have doesn't work for ASAN, but I think we need to determine that.
Hmm, I see in glibc that they also do prctl;
int
__pthread_setname_np (pthread_t th, const char *name)
{
const struct pthread *pd = (const struct pthread *) th;
/* Unfortunately the kernel headers do not export the TASK_COMM_LEN
macro. So we have to define it here. */
#define TASK_COMM_LEN 16
size_t name_len = strlen (name);
if (name_len >= TASK_COMM_LEN)
return ERANGE;
if (pd == THREAD_SELF)
return __prctl (PR_SET_NAME, name) ? errno : 0;
#define FMT "/proc/self/task/%u/comm"
char fname[sizeof (FMT) + 8];
sprintf (fname, FMT, (unsigned int) pd->tid);
int fd = __open64_nocancel (fname, O_RDWR);
if (fd == -1)
return errno;
int res = 0;
ssize_t n = TEMP_FAILURE_RETRY (__write_nocancel (fd, name, name_len));
if (n < 0)
res = errno;
else if (n != name_len)
res = EIO;
__close_nocancel_nostatus (fd);
return res;
}
No idea why this doesn't work on my machines. I run Fedora 42 and Debian 12. Will look a bit deeper.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27395#discussion_r2371223381
More information about the hotspot-dev
mailing list