Try to make scope info logging more robust.
Add checks for validity of Vehicle ptrs in scope_dumper::VehicleInfo. In Unix mode, try to handle SIGSEGVs when dumping scope info.
This commit is contained in:
@@ -251,6 +251,38 @@ class CrashLogUnix : public CrashLog {
|
||||
#endif
|
||||
return buffer + seprintf(buffer, last, "\n");
|
||||
}
|
||||
|
||||
#if defined(USE_SCOPE_INFO) && defined(__GLIBC__)
|
||||
/**
|
||||
* This is a wrapper around the generic LogScopeInfo function which sets
|
||||
* up a signal handler to catch any SIGSEGVs which may occur due to invalid data
|
||||
*/
|
||||
/* virtual */ char *LogScopeInfo(char *buffer, const char *last) const
|
||||
{
|
||||
logStacktraceSavedBuffer = buffer;
|
||||
|
||||
if (setjmp(logStacktraceJmpBuf) != 0) {
|
||||
buffer = logStacktraceSavedBuffer;
|
||||
buffer += seprintf(buffer, last, "\nSomething went seriously wrong when attempting to dump the scope info (SIGSEGV in signal handler).\n");
|
||||
buffer += seprintf(buffer, last, "This is probably due to an invalid pointer or other corrupt data.\n\n");
|
||||
return buffer;
|
||||
}
|
||||
|
||||
signal(SIGSEGV, LogStacktraceSigSegvHandler);
|
||||
sigset_t sigs;
|
||||
sigset_t oldsigs;
|
||||
sigemptyset(&sigs);
|
||||
sigaddset(&sigs, SIGSEGV);
|
||||
sigprocmask(SIG_UNBLOCK, &sigs, &oldsigs);
|
||||
|
||||
buffer = this->CrashLog::LogScopeInfo(buffer, last);
|
||||
|
||||
signal(SIGSEGV, SIG_DFL);
|
||||
sigprocmask(SIG_SETMASK, &oldsigs, NULL);
|
||||
return buffer;
|
||||
}
|
||||
#endif
|
||||
|
||||
public:
|
||||
/**
|
||||
* A crash log is always generated by signal.
|
||||
|
Reference in New Issue
Block a user