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

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