Add (default off) support for dying on malloc in RT code
Our malloc is not realtime. We shouldn't be using it in RT code. To
enforce this, add a hook into tcmalloc to LOG_RAW(FATAL) whenever an
application tries to allocate memory inside code running at the RT
priority level.
We have code in our drivetrain code which is allocating memory still
when realtime. That prevents us from enabling it yet.
Change-Id: I7679bb11fc9ef0cc676c77f5ef7b041427e1f32a
diff --git a/aos/init.cc b/aos/init.cc
index 51e22cf..71eeabd 100644
--- a/aos/init.cc
+++ b/aos/init.cc
@@ -39,6 +39,7 @@
// Common stuff that needs to happen at the beginning of both the realtime and
// non-realtime initialization sequences. May be called twice.
void InitStart() {
+ RegisterMallocHook();
if (FLAGS_coredump) {
WriteCoreDumps();
}
@@ -58,6 +59,8 @@
google::InitGoogleLogging((*argv)[0]);
gflags::ParseCommandLineFlags(argc, argv, true);
google::InstallFailureSignalHandler();
+
+ RegisterMallocHook();
}
void InitNRT() {