Skip to content

Commit 2aa3eec

Browse files
rorthyuxuanchen1997
authored andcommitted
[sanitizer_common] Fix TgKill on Solaris (#98000)
Summary: 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. Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60251717
1 parent 613544c commit 2aa3eec

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,9 @@ int TgKill(pid_t pid, tid_t tid, int sig) {
574574
return internal_syscall(SYSCALL(thr_kill2), pid, tid, sig);
575575
# elif SANITIZER_SOLARIS
576576
(void)pid;
577-
return thr_kill(tid, sig);
577+
errno = thr_kill(tid, sig);
578+
// TgKill is expected to return -1 on error, not an errno.
579+
return errno != 0 ? -1 : 0;
578580
# endif
579581
}
580582
# endif

0 commit comments

Comments
 (0)