Make raise/abort work with stale cached pid/tid values.
Switch raise to using tgkill with direct syscalls of getpid/gettid,
and switch abort to use raise(SIGABRT).
Bug: http://b/37769298
Test: debuggerd_test
Change-Id: If6f9d17fd8ae6177e742dc9f2f44bd78539431ba
(cherry picked from commit bf2af69fb2ff1365f4075d0207d6a895bc2727ed)
diff --git a/libc/bionic/raise.cpp b/libc/bionic/raise.cpp
index b134b5a..1f204d4 100644
--- a/libc/bionic/raise.cpp
+++ b/libc/bionic/raise.cpp
@@ -27,14 +27,14 @@
*/
#include <errno.h>
-#include <pthread.h>
#include <signal.h>
+#include <unistd.h>
+#include <sys/syscall.h>
int raise(int sig) {
- int rc = pthread_kill(pthread_self(), sig);
- if (rc != 0) {
- errno = rc;
- return -1;
- }
- return 0;
+ // Protect ourselves against stale cached PID/TID values by fetching them via syscall.
+ // http://b/37769298
+ pid_t pid = syscall(__NR_getpid);
+ pid_t tid = syscall(__NR_gettid);
+ return tgkill(pid, tid, sig);
}