Unverified Commit 6b4ae919 authored by Wang Yuan's avatar Wang Yuan Committed by GitHub
Browse files

Fix data race in bugReportStart (#7700)

The previous fix using _Atomic was insufficient, since we check and set it in
different places.

The implications of this bug are just that a portion of the bug report will be shown
twice, in the race case of two concurrent crashes.
parent 5449a2a8
......@@ -55,7 +55,8 @@ typedef ucontext_t sigcontext_t;
#endif
/* Globals */
static _Atomic int bug_report_start = 0; /* True if bug report header was already logged. */
static int bug_report_start = 0; /* True if bug report header was already logged. */
static pthread_mutex_t bug_report_start_mutex = PTHREAD_MUTEX_INITIALIZER;
/* Forward declarations */
void bugReportStart(void);
......@@ -919,11 +920,13 @@ void _serverPanic(const char *file, int line, const char *msg, ...) {
}
void bugReportStart(void) {
pthread_mutex_lock(&bug_report_start_mutex);
if (bug_report_start == 0) {
serverLogRaw(LL_WARNING|LL_RAW,
"\n\n=== REDIS BUG REPORT START: Cut & paste starting from here ===\n");
bug_report_start = 1;
}
pthread_mutex_unlock(&bug_report_start_mutex);
}
#ifdef HAVE_BACKTRACE
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment