log stack trace on core/segfault.

This commit is contained in:
Matt
2015-01-10 12:05:39 -08:00
parent f9ccc342a7
commit ef7b0c54fd
9 changed files with 42 additions and 10 deletions

@ -3435,10 +3435,12 @@ bool Addresses::setGeocoderLatLons ( void *state,
else { char *xx=NULL; *xx=0; }
*p++ = ' ';
// get state abbr
if ( aa->m_adm1 )
if ( aa->m_adm1 ) {
memcpy(p,aa->m_adm1->m_adm1,2);
else if ( aa->m_zip )
}
else if ( aa->m_zip ) {
memcpy(p,aa->m_zip->m_adm1,2);
}
else if ( aa->m_flags3 & AF2_LATLON );
else { char *xx=NULL;*xx=0; }
p += 2;

@ -969,6 +969,25 @@ void sigpwrHandler ( int x , siginfo_t *info , void *y ) {
g_loop.m_shutdown = 3;
}
#include <execinfo.h>
void printStackTrace ( int signum , siginfo_t *info , void *ptr ) {
logf(LOG_DEBUG,"gb: seg fault. printing stack trace.");
static void *s_bt[200];
int sz = backtrace(s_bt, 200);
//char **strings = backtrace_symbols(s_bt, sz);
for( int i = 0; i < sz; ++i) {
unsigned long long ba;
ba = g_profiler.getFuncBaseAddr((PTRTYPE)s_bt[i]);
//sigsegv_outp("%s", strings[i]);
logf(LOG_DEBUG,"[0x%llx->0x%llx] %s"
,(unsigned long long)s_bt[i]
,ba
,g_profiler.getFnName(ba,0));
}
}
// TODO: if we get a segfault while saving, what then?
void sigbadHandler ( int x , siginfo_t *info , void *y ) {
@ -997,6 +1016,11 @@ void sigbadHandler ( int x , siginfo_t *info , void *y ) {
log("loop: sigbadhandler. shutdown already called.");
return;
}
// unwind
printStackTrace( x , info , y );
// if we're a thread, let main process know to shutdown
g_loop.m_shutdown = 2;
log("loop: sigbadhandler. trying to save now. mode=%"INT32"",

@ -87,10 +87,12 @@ bool sendPagePerf ( TcpSocket *s , HttpRequest *r ) {
//get the 'path' part of the request.
char rbuf[1024];
if(r->getRequestLen() > 1023)
if(r->getRequestLen() > 1023) {
memcpy( rbuf, r->getRequest(), 1023);
else
}
else {
memcpy( rbuf, r->getRequest(), r->getRequestLen());
}
char* rbufEnd = rbuf;
//skip GET
while (!isspace(*rbufEnd)) rbufEnd++;

@ -3240,7 +3240,7 @@ void Parms::setParm ( char *THIS , Parm *m , int32_t mm , int32_t j , char *s ,
memcmp ( dst , s , len ) == 0 )
return;
// this means that we can not use string POINTERS as parms!!
if ( ! isHtmlEncoded ) memcpy ( dst , s , len );
if ( ! isHtmlEncoded ) {memcpy ( dst , s , len ); }
else len = htmlDecode (dst , s,len,false,0);
dst[len] = '\0';
// . might have to set length

@ -1412,6 +1412,9 @@ Profiler::checkMissedQuickPoll( FrameTrace *frame,
if(ptr) ++ptr[1];
}
// from memcpy.cpp
extern int g_inMemCpy;
void
Profiler::getStackFrame(int sig) {
void *trace[32];

@ -263,7 +263,7 @@ protected:
int32_t m_lastQPUsed;
uint64_t m_fnTime[11];
private:
public://private:
// Realtime profiler stuff
uint32_t getFuncBaseAddr(const uint32_t address);
uint32_t getFuncBaseAddr(const char *funcName);

@ -648,7 +648,7 @@ int32_t Xml::getText ( char *buf ,
// store it as-is if not filtering or not html entity
//simplecopy:
// if more than 1 byte in char, use memcpy
if ( cs > 1 ) memcpy ( dst , src , cs );
if ( cs > 1 ) {memcpy ( dst , src , cs );}
else *dst = *src;
}
// continue looping over nodes (text and tag nodes)
@ -764,7 +764,7 @@ int32_t Xml::getMetaContent (char *buf, int32_t bufLen, char *field, int32_t fie
continue;
}
// if more than 1 byte in char, use memcpy
if ( cs > 1 ) memcpy ( dst , src , cs );
if ( cs > 1 ) {memcpy ( dst , src , cs );}
else *dst = *src;
dst += cs;
}

@ -10588,6 +10588,7 @@ uint8_t *XmlDoc::getRootLangId ( ) {
}
XmlDoc **XmlDoc::getOldXmlDoc ( ) {
if ( m_oldDocValid ) return &m_oldDoc;
// note it

@ -1,5 +1,5 @@
#ifndef __GB_INCLUDE_H__
#define __GB_INCLUDE_H__
#ifndef GB_INCLUDE_H
#define GB_INCLUDE_H
// fix on 64-bit architectures so sizeof(uint96_t) is 12, not 16!
//#pragma pack(0)