[sanitizer_common] Fix TgKill on Solaris (#98000)

While working on safestack on Solaris, I noticed that the `TgKill`
implementation is wrong here: `TgKill` is supposed to return `-1` on
error, while `thr_kill` returns `errno` instead. This patch compensates
for that.

This went unnoticed so far since `TgKill` has been unused.

Tested on `amd64-pc-solaris2.11` and `sparcv9-sun-solaris2.11` together
with a subsequent patch to make safestack actually work on Solaris.
This commit is contained in:
Rainer Orth 2024-07-16 15:50:51 +02:00 committed by GitHub
parent fdf94e1632
commit 009e176b88
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -574,7 +574,9 @@ int TgKill(pid_t pid, tid_t tid, int sig) {
return internal_syscall(SYSCALL(thr_kill2), pid, tid, sig);
# elif SANITIZER_SOLARIS
(void)pid;
return thr_kill(tid, sig);
errno = thr_kill(tid, sig);
// TgKill is expected to return -1 on error, not an errno.
return errno != 0 ? -1 : 0;
# endif
}
# endif