Make RAW_LOG(FATAL) work while RT.
Generating the backtrace was allocating memory. Which would then die
again... So, drop RT permission on the way down.
Change-Id: Iaa14beb029b2d09f208179f81fdb9d62f3209163
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/third_party/google-glog/src/raw_logging.cc b/third_party/google-glog/src/raw_logging.cc
index 7a7409b..efe6e7d 100644
--- a/third_party/google-glog/src/raw_logging.cc
+++ b/third_party/google-glog/src/raw_logging.cc
@@ -66,6 +66,16 @@
# define safe_write(fd, s, len) write(fd, s, len)
#endif
+namespace aos {
+void FatalUnsetRealtimePriority() __attribute__((weak));
+}
+
+static void MaybeUnsetRealtime() {
+ if (&aos::FatalUnsetRealtimePriority != nullptr) {
+ aos::FatalUnsetRealtimePriority();
+ }
+}
+
_START_GOOGLE_NAMESPACE_
// Data for RawLog__ below. We simply pick up the latest
@@ -152,6 +162,7 @@
// We write just once to avoid races with other invocations of RawLog__.
safe_write(STDERR_FILENO, buffer, strlen(buffer));
if (severity == GLOG_FATAL) {
+ MaybeUnsetRealtime();
if (!sync_val_compare_and_swap(&crashed, false, true)) {
crash_reason.filename = file;
crash_reason.line_number = line;