Fix crash report killed by message (#8683)

We sometimes see the crash report saying we were killed by a random
process even in cases where the crash was spontanius in redis.
for instance, crashes found by the corrupt-dump test.

It looks like this si_pid is sometimes left uninitialized, and a good
way to tell if the crash originated in redis or trigged by outside is to
look at si_code, real signal codes are always > 0, and ones generated by
kill are have si_code of 0 or below.
This commit is contained in:
Oran Agra 2021-03-24 08:33:24 +02:00 committed by GitHub
parent 895fb348f4
commit dd8cefdeea

View File

@ -1809,7 +1809,7 @@ void sigsegvHandler(int sig, siginfo_t *info, void *secret) {
serverLog(LL_WARNING, serverLog(LL_WARNING,
"Accessing address: %p", (void*)info->si_addr); "Accessing address: %p", (void*)info->si_addr);
} }
if (info->si_pid != -1) { if (info->si_code <= SI_USER && info->si_pid != -1) {
serverLog(LL_WARNING, "Killed by PID: %ld, UID: %d", (long) info->si_pid, info->si_uid); serverLog(LL_WARNING, "Killed by PID: %ld, UID: %d", (long) info->si_pid, info->si_uid);
} }