summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc
diff options
context:
space:
mode:
authorKostya Kortchinsky <kostyak@google.com>2018-04-10 14:41:40 +0000
committerKostya Kortchinsky <kostyak@google.com>2018-04-10 14:41:40 +0000
commit141139e695b9be514ccafa9d4ac12bd2ad122cd6 (patch)
treed785f85485b6644aa73faba8b11b3cb02fa5a81e /compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc
parentb7243ed2f406a30625c365e8e7ed04827dd3ee95 (diff)
downloadbcm5719-llvm-141139e695b9be514ccafa9d4ac12bd2ad122cd6.tar.gz
bcm5719-llvm-141139e695b9be514ccafa9d4ac12bd2ad122cd6.zip
[sanitizer] Allow BackgroundThread to not depend on StackDepot v2
Summary: This is a redo of D45296. It looks like the random stack-protector issues I was getting were coming from my Android emulator, and updating everything all around and relaunching stuff ended up making it go away. I guess I'll have to see how it behaves on the bots. Only additional change from the previous CL is some `const` were appropriate. Reviewers: alekseyshl Reviewed By: alekseyshl Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D45461 llvm-svn: 329706
Diffstat (limited to 'compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc')
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc30
1 files changed, 18 insertions, 12 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc b/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc
index 9c24c30749c..5e56e31fe6a 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc
@@ -18,7 +18,6 @@
#include "sanitizer_flags.h"
#include "sanitizer_procmaps.h"
#include "sanitizer_report_decorator.h"
-#include "sanitizer_stackdepot.h"
#include "sanitizer_stacktrace.h"
#include "sanitizer_symbolizer.h"
@@ -113,17 +112,22 @@ void SetSoftRssLimitExceededCallback(void (*Callback)(bool exceeded)) {
}
#if SANITIZER_LINUX && !SANITIZER_GO
+// Weak default implementation for when sanitizer_stackdepot is not linked in.
+SANITIZER_WEAK_ATTRIBUTE StackDepotStats *StackDepotGetStats() {
+ return nullptr;
+}
+
void BackgroundThread(void *arg) {
- uptr hard_rss_limit_mb = common_flags()->hard_rss_limit_mb;
- uptr soft_rss_limit_mb = common_flags()->soft_rss_limit_mb;
- bool heap_profile = common_flags()->heap_profile;
+ const uptr hard_rss_limit_mb = common_flags()->hard_rss_limit_mb;
+ const uptr soft_rss_limit_mb = common_flags()->soft_rss_limit_mb;
+ const bool heap_profile = common_flags()->heap_profile;
uptr prev_reported_rss = 0;
uptr prev_reported_stack_depot_size = 0;
bool reached_soft_rss_limit = false;
uptr rss_during_last_reported_profile = 0;
while (true) {
SleepForMillis(100);
- uptr current_rss_mb = GetRSS() >> 20;
+ const uptr current_rss_mb = GetRSS() >> 20;
if (Verbosity()) {
// If RSS has grown 10% since last time, print some information.
if (prev_reported_rss * 11 / 10 < current_rss_mb) {
@@ -132,13 +136,15 @@ void BackgroundThread(void *arg) {
}
// If stack depot has grown 10% since last time, print it too.
StackDepotStats *stack_depot_stats = StackDepotGetStats();
- if (prev_reported_stack_depot_size * 11 / 10 <
- stack_depot_stats->allocated) {
- Printf("%s: StackDepot: %zd ids; %zdM allocated\n",
- SanitizerToolName,
- stack_depot_stats->n_uniq_ids,
- stack_depot_stats->allocated >> 20);
- prev_reported_stack_depot_size = stack_depot_stats->allocated;
+ if (stack_depot_stats) {
+ if (prev_reported_stack_depot_size * 11 / 10 <
+ stack_depot_stats->allocated) {
+ Printf("%s: StackDepot: %zd ids; %zdM allocated\n",
+ SanitizerToolName,
+ stack_depot_stats->n_uniq_ids,
+ stack_depot_stats->allocated >> 20);
+ prev_reported_stack_depot_size = stack_depot_stats->allocated;
+ }
}
}
// Check RSS against the limit.
OpenPOWER on IntegriCloud