bpftrace/SOURCES/bpftrace-0.10.0-Remove-RLIMIT_AS-limit.patch
2021-09-09 15:07:40 +00:00

74 lines
2.2 KiB
Diff

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