Commit 44f5700d authored by Tollef Fog Heen's avatar Tollef Fog Heen

Lock panic buffer before mangling it

If we were panic-ing in multiple threads at the same time, the panic
buffer would be partially overwritten.  Prevent this with a mutex
parent be1eb036
......@@ -34,6 +34,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#ifndef HAVE_EXECINFO_H
#include "compat/execinfo.h"
......@@ -56,6 +57,7 @@
*/
static struct vsb vsps, *vsp;
pthread_mutex_t panicstr_mtx = PTHREAD_MUTEX_INITIALIZER;
/*--------------------------------------------------------------------*/
......@@ -294,6 +296,9 @@ pan_ic(const char *func, const char *file, int line, const char *cond,
const char *q;
const struct sess *sp;
AZ(pthread_mutex_lock(&panicstr_mtx)); /* Won't be released,
we're going to die
anyway */
switch(xxx) {
case 3:
VSB_printf(vsp,
......
......@@ -288,7 +288,7 @@ VSL_Init(void)
vsl_wrap();
VSM_head->starttime = (intmax_t)TIM_real();
VSM_head->panicstr[0] = '\0';
memset(VSM_head->panicstr, '\0', sizeof *VSM_head->panicstr);
memset(VSC_C_main, 0, sizeof *VSC_C_main);
VSM_head->child_pid = getpid();
}
......
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