Skip to content

Commit

Permalink
fix #4837:
Browse files Browse the repository at this point in the history
don't try to hide signalhandler from stacktrace / fix endless loop
-> crashhandler should be as simple as possible
  • Loading branch information
abma committed Jun 30, 2015
1 parent 57347d9 commit 81b537a
Showing 1 changed file with 13 additions and 31 deletions.
44 changes: 13 additions & 31 deletions rts/System/Platform/Linux/CrashHandler.cpp
Expand Up @@ -529,7 +529,7 @@ static void LogStacktrace(const int logLevel, StackTrace& stacktrace)
const std::string& exe_path = Platform::GetProcessExecutablePath();
const std::string& cwd_path = Platform::GetOrigCWD();
for (auto fit = stacktrace.begin(); fit != stacktrace.end(); fit++) {
for (auto eit = fit->entries.begin(); eit != fit->entries.end(); eit++) {
for (auto eit = fit->entries.begin(); eit != fit->entries.end(); eit++) {
eit->abbrev_funcname = eit->funcname;
std::string fileline = eit->fileline;
if (fileline[1] == '?') { // case "??:?", ":?"
Expand All @@ -551,37 +551,19 @@ static void LogStacktrace(const int logLevel, StackTrace& stacktrace)
}

colFileline = std::max(colFileline, (int)eit->abbrev_fileline.length());
}
}
}
}

bool hideSignalHandler = true;

// Print out the translated StackTrace
unsigned numLine = 0;
unsigned hiddenLines = 0;
while (numLine == 0) { // outer loop at most twice -- tries to find the signal handler once and if that doesn't work, then just print every frame
for (auto fit = stacktrace.cbegin(); fit != stacktrace.cend(); fit++) {
for (auto eit = fit->entries.begin(); eit != fit->entries.end(); eit++) {

if (hideSignalHandler) {
hiddenLines++;
if (eit->fileline.find("sigaction.c:?") == 0) {
hideSignalHandler = false;
LOG_I(logLevel, "(Signal handler calls suppressed [%d]. Inlined calls denoted by < > brackets.)", hiddenLines);
}
continue;
}

if (eit->inLine) {
LOG_I(logLevel, " <%02u> %*s %s", fit->level, colFileline, eit->abbrev_fileline.c_str(), eit->abbrev_funcname.c_str());
} else {
LOG_I(logLevel, "[%02u] %*s %s", fit->level, colFileline, eit->abbrev_fileline.c_str(), eit->abbrev_funcname.c_str());
}
numLine++;
}
}
hideSignalHandler = false;
}
// Print out the translated StackTrace
for (auto fit = stacktrace.cbegin(); fit != stacktrace.cend(); fit++) {
for (auto eit = fit->entries.begin(); eit != fit->entries.end(); eit++) {
if (eit->inLine) {
LOG_I(logLevel, " <%02u> %*s %s", fit->level, colFileline, eit->abbrev_fileline.c_str(), eit->abbrev_funcname.c_str());
} else {
LOG_I(logLevel, "[%02u] %*s %s", fit->level, colFileline, eit->abbrev_fileline.c_str(), eit->abbrev_funcname.c_str());
}
}
}
}

#endif // !(__APPLE__)
Expand Down

1 comment on commit 81b537a

@ashdnazg
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool!

Please sign in to comment.