tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

compiler-rt-rss-limit-heap-profile.patch (2746B)


      1 diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
      2 index 8fd398564280..b7c4820971bb 100644
      3 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
      4 +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
      5 @@ -29,6 +29,7 @@ void *BackgroundThread(void *arg) {
      6   const uptr hard_rss_limit_mb = common_flags()->hard_rss_limit_mb;
      7   const uptr soft_rss_limit_mb = common_flags()->soft_rss_limit_mb;
      8   const bool heap_profile = common_flags()->heap_profile;
      9 +  const bool rss_limit_heap_profile = common_flags()->rss_limit_heap_profile;
     10   uptr prev_reported_rss = 0;
     11   uptr prev_reported_stack_depot_size = 0;
     12   bool reached_soft_rss_limit = false;
     13 @@ -56,6 +57,10 @@ void *BackgroundThread(void *arg) {
     14       Report("%s: hard rss limit exhausted (%zdMb vs %zdMb)\n",
     15              SanitizerToolName, hard_rss_limit_mb, current_rss_mb);
     16       DumpProcessMap();
     17 +      if (rss_limit_heap_profile) {
     18 +        Printf("\n\nHEAP PROFILE at RSS %zdMb\n", current_rss_mb);
     19 +        __sanitizer_print_memory_profile(90, 20);
     20 +      }
     21       Die();
     22     }
     23     if (soft_rss_limit_mb) {
     24 @@ -63,6 +68,11 @@ void *BackgroundThread(void *arg) {
     25         reached_soft_rss_limit = true;
     26         Report("%s: soft rss limit exhausted (%zdMb vs %zdMb)\n",
     27                SanitizerToolName, soft_rss_limit_mb, current_rss_mb);
     28 +        if (rss_limit_heap_profile) {
     29 +          Printf("\n\nHEAP PROFILE at RSS %zdMb\n", current_rss_mb);
     30 +          __sanitizer_print_memory_profile(90, 20);
     31 +          rss_during_last_reported_profile = current_rss_mb;
     32 +        }
     33         SetRssLimitExceeded(true);
     34       } else if (soft_rss_limit_mb >= current_rss_mb &&
     35                  reached_soft_rss_limit) {
     36 diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc b/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc
     37 index 6148ae56067c..a0fbb8e14bd5 100644
     38 --- a/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc
     39 +++ b/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc
     40 @@ -147,6 +147,9 @@ COMMON_FLAG(uptr, max_allocation_size_mb, 0,
     41             "If non-zero, malloc/new calls larger than this size will return "
     42             "nullptr (or crash if allocator_may_return_null=false).")
     43 COMMON_FLAG(bool, heap_profile, false, "Experimental heap profiler, asan-only")
     44 +COMMON_FLAG(bool, rss_limit_heap_profile, false,
     45 +            "Experimental heap profiler (only when hard/soft rss limit "
     46 +            "exceeded, asan-only")
     47 COMMON_FLAG(s32, allocator_release_to_os_interval_ms,
     48             ((bool)SANITIZER_FUCHSIA || (bool)SANITIZER_WINDOWS) ? -1 : 5000,
     49             "Only affects a 64-bit allocator. If set, tries to release unused "