Blame SOURCES/bpftrace-0.10.0-Remove-RLIMIT_AS-limit.patch

18bb42
From 604c9d5619ca01a46c208a70b7beec3041ba77a9 Mon Sep 17 00:00:00 2001
18bb42
From: Daniel Xu <dxu@dxuuu.xyz>
18bb42
Date: Thu, 28 May 2020 23:12:47 -0700
18bb42
Subject: [PATCH] Remove RLIMIT_AS limit
18bb42
18bb42
We haven't seen any OOM issues in a while so I suspect either our type
18bb42
fixes in bpftrace or upstream llvm changes have resolved the issue.
18bb42
18bb42
This closes #1355.
18bb42
---
18bb42
 src/CMakeLists.txt |  1 -
18bb42
 src/main.cpp       | 26 --------------------------
18bb42
 2 files changed, 27 deletions(-)
18bb42
18bb42
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
18bb42
index 4fa0418..ac040f4 100644
18bb42
--- a/src/CMakeLists.txt
18bb42
+++ b/src/CMakeLists.txt
18bb42
@@ -99,7 +99,6 @@ if (BUILD_ASAN)
18bb42
     # target_link_options is supported in CMake 3.13 and newer
18bb42
     message("Please use CMake 3.13 or newer to enable ASAN")
18bb42
   endif()
18bb42
-  target_compile_definitions(bpftrace PRIVATE BUILD_ASAN)
18bb42
   target_compile_options(bpftrace PUBLIC "-fsanitize=address")
18bb42
   target_link_options(bpftrace PUBLIC "-fsanitize=address")
18bb42
 endif()
18bb42
diff --git a/src/main.cpp b/src/main.cpp
18bb42
index 4ff9d37..d92ea8d 100644
18bb42
--- a/src/main.cpp
18bb42
+++ b/src/main.cpp
18bb42
@@ -92,30 +92,6 @@ static void enforce_infinite_rlimit() {
18bb42
         "\"ulimit -l 8192\" to fix the problem" << std::endl;
18bb42
 }
18bb42
 
18bb42
-#ifdef BUILD_ASAN
18bb42
-static void cap_memory_limits()
18bb42
-{
18bb42
-}
18bb42
-#else
18bb42
-static void cap_memory_limits() {
18bb42
-  struct rlimit rl = {};
18bb42
-  int err;
18bb42
-  uint64_t memory_limit_bytes = 1 * 1024 * 1024 * 1024;
18bb42
-
18bb42
-  // this is a safety measure for issue #528 "LLVM ERROR: out of memory",
18bb42
-  // and caps bpftrace memory to 1 Gbyte. This may be removed once the LLVM
18bb42
-  // issue has been fixed, and this is no longer deemed necessary.
18bb42
-  rl.rlim_max = memory_limit_bytes;
18bb42
-  rl.rlim_cur = rl.rlim_max;
18bb42
-  err = setrlimit(RLIMIT_AS, &rl);
18bb42
-  err += setrlimit(RLIMIT_RSS, &rl);
18bb42
-  if (err)
18bb42
-    std::cerr << std::strerror(err)<<": couldn't set RLIMIT_AS and " <<
18bb42
-        "RLIMIT_RSS for bpftrace (these are a temporary precaution to stop " <<
18bb42
-        "accidental large program loads, and are not required" << std::endl;
18bb42
-}
18bb42
-#endif // BUILD_ASAN
18bb42
-
18bb42
 bool is_root()
18bb42
 {
18bb42
   if (geteuid() != 0)
18bb42
@@ -425,8 +401,6 @@ int main(int argc, char *argv[])
18bb42
   // rlimit?
18bb42
   enforce_infinite_rlimit();
18bb42
 
18bb42
-  cap_memory_limits();
18bb42
-
18bb42
   // positional parameters
18bb42
   while (optind < argc) {
18bb42
     bpftrace.add_param(argv[optind]);
18bb42
-- 
18bb42
2.25.4
18bb42