aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2017-03-26 23:22:44 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-27 14:54:51 +0000
commit59eed0db9909c4a097f5929e1a12bc53552ac6fb (patch)
tree89f2b1c1d8b3a7a76df2da670f4ee45f6cd437b1 /tools
parent73a850fe5db820b548d61741191d5ed966d3914b (diff)
ok: handle concurrent crashes better
lockf() is a simple way to prevent interlaced stack traces when there are concurrent crashes. After a crashing process rethrows its signal and dies for real, the OS unlocks the file for other processes. I tested this by making SkCanvas::drawRRect() crash on Linux: 20-odd GM crashes with interlaced stack traces before, none after. Change-Id: I99930756b8c85c552eef7c3a77778e4c00d34c42 Reviewed-on: https://skia-review.googlesource.com/10177 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/ok.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/tools/ok.cpp b/tools/ok.cpp
index e4bf739e7d..b6d25b840c 100644
--- a/tools/ok.cpp
+++ b/tools/ok.cpp
@@ -38,6 +38,9 @@ static thread_local const char* tls_name = "";
for (int sig : std::vector<int>{ SIGABRT, SIGBUS, SIGFPE, SIGILL, SIGSEGV }) {
original_handlers[sig] = signal(sig, [](int sig) {
+ // To prevent interlaced output, lock the stacktrace log file until we die.
+ lockf(crash_stacktrace_fd, F_LOCK, 0);
+
auto ez_write = [](const char* str) {
write(crash_stacktrace_fd, str, strlen(str));
};