1*4882a593SmuzhiyunFrom 2fa414c8655c421e7eb0bb1719928babb0ecf7c6 Mon Sep 17 00:00:00 2001
2*4882a593SmuzhiyunFrom: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
3*4882a593SmuzhiyunDate: Thu, 26 Dec 2019 22:21:33 +0100
4*4882a593SmuzhiyunSubject: [PATCH] src/client/linux/handler/exception_handler.cc: rename tgkill
5*4882a593Smuzhiyun to BreakpadTgkill()
6*4882a593SmuzhiyunMIME-Version: 1.0
7*4882a593SmuzhiyunContent-Type: text/plain; charset=UTF-8
8*4882a593SmuzhiyunContent-Transfer-Encoding: 8bit
9*4882a593Smuzhiyun
10*4882a593SmuzhiyunSince glibc 2.30, a tgkill() function was added in the C library, and
11*4882a593Smuzhiyunits definition obviously conflicts with the internal definition of
12*4882a593Smuzhiyungoogle-breakpad, causing build failures:
13*4882a593Smuzhiyun
14*4882a593Smuzhiyunsrc/client/linux/handler/exception_handler.cc:109:12: error: ‘int tgkill(pid_t, pid_t, int)’ was declared ‘extern’ and later ‘static’ [-fpermissive]
15*4882a593Smuzhiyun  109 | static int tgkill(pid_t tgid, pid_t tid, int sig) {
16*4882a593Smuzhiyun      |            ^~~~~~
17*4882a593SmuzhiyunIn file included from /usr/include/signal.h:374,
18*4882a593Smuzhiyun                 from ./src/client/linux/handler/exception_handler.h:33,
19*4882a593Smuzhiyun                 from src/client/linux/handler/exception_handler.cc:66:
20*4882a593Smuzhiyun/usr/include/bits/signal_ext.h:29:12: note: previous declaration of ‘int tgkill(__pid_t, __pid_t, int)’
21*4882a593Smuzhiyun   29 | extern int tgkill (__pid_t __tgid, __pid_t __tid, int __signal);
22*4882a593Smuzhiyun      |            ^~~~~~
23*4882a593Smuzhiyun
24*4882a593SmuzhiyunUpstream google-breakpad simply dropped the use of the internal
25*4882a593Smuzhiyuntgkill() in commit
26*4882a593Smuzhiyunhttps://chromium.googlesource.com/breakpad/breakpad/+/7e3c165000d44fa153a3270870ed500bc8bbb461. However,
27*4882a593Smuzhiyunthis is not realistic for Buildroot, since we do support old systems
28*4882a593Smuzhiyunwhere the system C library will not necessarily provide tgkill().
29*4882a593Smuzhiyun
30*4882a593SmuzhiyunSigned-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
31*4882a593Smuzhiyun---
32*4882a593Smuzhiyun src/client/linux/handler/exception_handler.cc | 4 ++--
33*4882a593Smuzhiyun 1 file changed, 2 insertions(+), 2 deletions(-)
34*4882a593Smuzhiyun
35*4882a593Smuzhiyundiff --git a/src/client/linux/handler/exception_handler.cc b/src/client/linux/handler/exception_handler.cc
36*4882a593Smuzhiyunindex b63f973b..b4c279b8 100644
37*4882a593Smuzhiyun--- a/src/client/linux/handler/exception_handler.cc
38*4882a593Smuzhiyun+++ b/src/client/linux/handler/exception_handler.cc
39*4882a593Smuzhiyun@@ -106,7 +106,7 @@
40*4882a593Smuzhiyun #endif
41*4882a593Smuzhiyun
42*4882a593Smuzhiyun // A wrapper for the tgkill syscall: send a signal to a specific thread.
43*4882a593Smuzhiyun-static int tgkill(pid_t tgid, pid_t tid, int sig) {
44*4882a593Smuzhiyun+static int BreakpadTgkill(pid_t tgid, pid_t tid, int sig) {
45*4882a593Smuzhiyun   return syscall(__NR_tgkill, tgid, tid, sig);
46*4882a593Smuzhiyun   return 0;
47*4882a593Smuzhiyun }
48*4882a593Smuzhiyun@@ -387,7 +387,7 @@ void ExceptionHandler::SignalHandler(int sig, siginfo_t* info, void* uc) {
49*4882a593Smuzhiyun     // In order to retrigger it, we have to queue a new signal by calling
50*4882a593Smuzhiyun     // kill() ourselves.  The special case (si_pid == 0 && sig == SIGABRT) is
51*4882a593Smuzhiyun     // due to the kernel sending a SIGABRT from a user request via SysRQ.
52*4882a593Smuzhiyun-    if (tgkill(getpid(), syscall(__NR_gettid), sig) < 0) {
53*4882a593Smuzhiyun+    if (BreakpadTgkill(getpid(), syscall(__NR_gettid), sig) < 0) {
54*4882a593Smuzhiyun       // If we failed to kill ourselves (e.g. because a sandbox disallows us
55*4882a593Smuzhiyun       // to do so), we instead resort to terminating our process. This will
56*4882a593Smuzhiyun       // result in an incorrect exit code.
57*4882a593Smuzhiyun--
58*4882a593Smuzhiyun2.24.1
59*4882a593Smuzhiyun
60