mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
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.
This commit is contained in:
parent
5449a2a8b5
commit
6b4ae919e8
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user