Commit ceaf73d7 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Make the panicstr a VSM allocation

parent 54e7eb52
...@@ -40,8 +40,6 @@ ...@@ -40,8 +40,6 @@
#include "cache.h" #include "cache.h"
#include "vapi/vsm_int.h"
#include "cache_backend.h" #include "cache_backend.h"
#include "waiter/cache_waiter.h" #include "waiter/cache_waiter.h"
#include "vcl.h" #include "vcl.h"
...@@ -58,6 +56,10 @@ ...@@ -58,6 +56,10 @@
static struct vsb vsps, *vsp; static struct vsb vsps, *vsp;
static pthread_mutex_t panicstr_mtx = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t panicstr_mtx = PTHREAD_MUTEX_INITIALIZER;
/* Initialized in mgt_shmem.c, points into VSM */
char *PAN_panicstr;
unsigned PAN_panicstr_len;
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
static void static void
...@@ -354,20 +356,8 @@ pan_ic(const char *func, const char *file, int line, const char *cond, ...@@ -354,20 +356,8 @@ pan_ic(const char *func, const char *file, int line, const char *cond,
VSB_bcat(vsp, "", 1); /* NUL termination */ VSB_bcat(vsp, "", 1); /* NUL termination */
if (cache_param->diag_bitmap & 0x4000) if (cache_param->diag_bitmap & 0x4000)
(void)fputs(VSM_head->panicstr, stderr); (void)fputs(PAN_panicstr, stderr);
#ifdef HAVE_ABORT2
if (cache_param->diag_bitmap & 0x8000) {
void *arg[1];
char *p;
for (p = VSM_head->panicstr; *p; p++)
if (*p == '\n')
*p = ' ';
arg[0] = VSM_head->panicstr;
abort2(VSM_head->panicstr, 1, arg);
}
#endif
if (cache_param->diag_bitmap & 0x1000) if (cache_param->diag_bitmap & 0x1000)
exit(4); exit(4);
else else
...@@ -382,6 +372,8 @@ PAN_Init(void) ...@@ -382,6 +372,8 @@ PAN_Init(void)
VAS_Fail = pan_ic; VAS_Fail = pan_ic;
vsp = &vsps; vsp = &vsps;
AN(VSB_new(vsp, VSM_head->panicstr, sizeof VSM_head->panicstr, AN(PAN_panicstr);
AN(PAN_panicstr_len);
AN(VSB_new(vsp, PAN_panicstr, PAN_panicstr_len,
VSB_FIXEDLEN)); VSB_FIXEDLEN));
} }
...@@ -317,7 +317,6 @@ VSL_Init(void) ...@@ -317,7 +317,6 @@ VSL_Init(void)
vsl_wrap(); vsl_wrap();
VSM_head->starttime = (intmax_t)VTIM_real(); VSM_head->starttime = (intmax_t)VTIM_real();
memset(VSM_head->panicstr, '\0', sizeof *VSM_head->panicstr);
memset(VSC_C_main, 0, sizeof *VSC_C_main); memset(VSC_C_main, 0, sizeof *VSC_C_main);
VSM_head->child_pid = getpid(); VSM_head->child_pid = getpid();
} }
......
...@@ -50,6 +50,9 @@ extern pid_t mgt_pid; ...@@ -50,6 +50,9 @@ extern pid_t mgt_pid;
/* mgt_shmem.c */ /* mgt_shmem.c */
extern struct VSC_C_main *VSC_C_main; extern struct VSC_C_main *VSC_C_main;
#define PAN_CLASS "Panic"
extern char *PAN_panicstr;
extern unsigned PAN_panicstr_len;
/* varnishd.c */ /* varnishd.c */
struct vsb; struct vsb;
......
...@@ -47,7 +47,6 @@ ...@@ -47,7 +47,6 @@
#include "common/heritage.h" #include "common/heritage.h"
#include "common/params.h" #include "common/params.h"
#include "vapi/vsm_int.h"
#include "vbm.h" #include "vbm.h"
#include "vcli.h" #include "vcli.h"
#include "vcli_priv.h" #include "vcli_priv.h"
...@@ -428,10 +427,10 @@ mgt_handle_panicstr(pid_t r) ...@@ -428,10 +427,10 @@ mgt_handle_panicstr(pid_t r)
{ {
char time_str[30]; char time_str[30];
if (VSM_head->panicstr[0] == '\0') if (PAN_panicstr[0] == '\0')
return; return;
REPORT(LOG_ERR, "Child (%jd) Panic message: %s", REPORT(LOG_ERR, "Child (%jd) Panic message: %s",
(intmax_t)r, VSM_head->panicstr); (intmax_t)r, PAN_panicstr);
if (child_panic) if (child_panic)
VSB_delete(child_panic); VSB_delete(child_panic);
...@@ -439,7 +438,7 @@ mgt_handle_panicstr(pid_t r) ...@@ -439,7 +438,7 @@ mgt_handle_panicstr(pid_t r)
XXXAN(child_panic); XXXAN(child_panic);
VTIM_format(VTIM_real(), time_str); VTIM_format(VTIM_real(), time_str);
VSB_printf(child_panic, "Last panic at: %s\n", time_str); VSB_printf(child_panic, "Last panic at: %s\n", time_str);
VSB_cat(child_panic, VSM_head->panicstr); VSB_cat(child_panic, PAN_panicstr);
AZ(VSB_finish(child_panic)); AZ(VSB_finish(child_panic));
} }
......
...@@ -843,9 +843,6 @@ static const struct parspec input_parspec[] = { ...@@ -843,9 +843,6 @@ static const struct parspec input_parspec[] = {
" 0x00001000 - do not core-dump child process.\n" " 0x00001000 - do not core-dump child process.\n"
" 0x00002000 - only short panic message.\n" " 0x00002000 - only short panic message.\n"
" 0x00004000 - panic to stderr.\n" " 0x00004000 - panic to stderr.\n"
#ifdef HAVE_ABORT2
" 0x00008000 - panic to abort2().\n"
#endif
" 0x00010000 - synchronize shmlog.\n" " 0x00010000 - synchronize shmlog.\n"
" 0x00020000 - synchronous start of persistence.\n" " 0x00020000 - synchronous start of persistence.\n"
" 0x00040000 - release VCL early.\n" " 0x00040000 - release VCL early.\n"
......
...@@ -331,6 +331,12 @@ mgt_SHM_Init(const char *l_arg) ...@@ -331,6 +331,12 @@ mgt_SHM_Init(const char *l_arg)
vsl_log_start[1] = VSL_ENDMARKER; vsl_log_start[1] = VSL_ENDMARKER;
VWMB(); VWMB();
PAN_panicstr_len = 64 * 1024;
PAN_panicstr = VSM_Alloc(PAN_panicstr_len, PAN_CLASS, "", "");
AN(PAN_panicstr);
/* XXX: shouldn't VSM_Alloc zero ? */
memset(PAN_panicstr, '\0', PAN_panicstr_len);
do do
*vsl_log_start = random() & 0xffff; *vsl_log_start = random() & 0xffff;
while (*vsl_log_start == 0); while (*vsl_log_start == 0);
......
...@@ -187,7 +187,6 @@ AC_CHECK_FUNCS([socket]) ...@@ -187,7 +187,6 @@ AC_CHECK_FUNCS([socket])
AC_CHECK_FUNCS([strptime]) AC_CHECK_FUNCS([strptime])
AC_CHECK_FUNCS([fmtcheck]) AC_CHECK_FUNCS([fmtcheck])
AC_CHECK_FUNCS([getdtablesize]) AC_CHECK_FUNCS([getdtablesize])
AC_CHECK_FUNCS([abort2])
AC_CHECK_FUNCS([timegm]) AC_CHECK_FUNCS([timegm])
AC_CHECK_FUNCS([nanosleep]) AC_CHECK_FUNCS([nanosleep])
AC_CHECK_FUNCS([setppriv]) AC_CHECK_FUNCS([setppriv])
......
...@@ -65,9 +65,6 @@ struct VSM_head { ...@@ -65,9 +65,6 @@ struct VSM_head {
unsigned shm_size; unsigned shm_size;
/* Panic message buffer */
char panicstr[64 * 1024];
unsigned alloc_seq; unsigned alloc_seq;
/* Must be last element */ /* Must be last element */
struct VSM_chunk head; struct VSM_chunk head;
......
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