From 96724cf1809ac9ab7185bb0421f3a1e1cb9b532d Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 29 May 2019 17:20:50 +0100 Subject: [PATCH] intercept: Abort via the equivalent of raise(SIGABRT) If we're crashing, raise(SIGABRT) is more debugging-friendly than _exit(1) - that way we'll leave a core dump behind. Signed-off-by: Simon McVittie --- src/intercept.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/intercept.c b/src/intercept.c index a6bc1516..fa82cd03 100644 --- a/src/intercept.c +++ b/src/intercept.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -501,6 +502,8 @@ void xabort_errno(int error_code, const char *msg) { static const char main_msg[] = " libsyscall_intercept error\n"; + int tid; + pid_t pid; if (msg != NULL) { /* not using libc - inline strlen */ @@ -527,7 +530,11 @@ xabort_errno(int error_code, const char *msg) } syscall_no_intercept(SYS_write, 2, main_msg, sizeof(main_msg) - 1); - syscall_no_intercept(SYS_exit_group, 1); + + /* abort(), but without using glibc */ + tid = syscall_no_intercept(SYS_gettid); + pid = syscall_no_intercept(SYS_getpid); + syscall(SYS_tgkill, pid, tid, SIGABRT); __builtin_unreachable(); }