Skip to content

Commit

Permalink
[sanitizer_common] Fix TgKill on Solaris (#98000)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rorth authored and yuxuanchen1997 committed Jul 25, 2024
1 parent 613544c commit 2aa3eec
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2aa3eec

Please sign in to comment.