aboutsummaryrefslogtreecommitdiff
path: root/driver/jvm_tooling.cpp
diff options
context:
space:
mode:
authorFabian Meumertzheim <meumertzheim@code-intelligence.com>2021-05-05 12:09:32 +0200
committerFabian Meumertzheim <fabian@meumertzhe.im>2021-05-07 16:38:22 +0200
commitf1c4bb507733710bbf292e474e173fcd0d6e8ff5 (patch)
tree1f4acc7f6380454b3965183e3937ce9a1635753d /driver/jvm_tooling.cpp
parentcca74efb030f4bfe941decd218bdfb489f490523 (diff)
downloadjazzer-api-f1c4bb507733710bbf292e474e173fcd0d6e8ff5.tar.gz
Ensure default -Xmx value is below -rss_limit_mb
libFuzzer defaults to an rss_limit_mb of 2048, but we start the JVM with -Xmx4096m. This can lead to libFuzzer OOM reports when a single allocation in Java exceeds 2 GB but still fits into the JVM heap. This is solved by letting the JVM heap size default to slightly less than 2 GB. This change is not fully backwards compatible, but will only cause targets to crash more often than they used to.
Diffstat (limited to 'driver/jvm_tooling.cpp')
-rw-r--r--driver/jvm_tooling.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/driver/jvm_tooling.cpp b/driver/jvm_tooling.cpp
index 0ee18f48..fee54377 100644
--- a/driver/jvm_tooling.cpp
+++ b/driver/jvm_tooling.cpp
@@ -153,8 +153,9 @@ JVM::JVM(const std::string &executable_path) {
std::vector<JavaVMOption> options;
options.push_back(
JavaVMOption{.optionString = const_cast<char *>(class_path.c_str())});
- // set the maximum heap size
- options.push_back(JavaVMOption{.optionString = (char *)"-Xmx4096m"});
+ // Set the maximum heap size to a value that is slightly smaller than
+ // libFuzzer's default rss_limit_mb. This prevents erroneous oom reports.
+ options.push_back(JavaVMOption{.optionString = (char *)"-Xmx2040m"});
options.push_back(JavaVMOption{.optionString = (char *)"-enableassertions"});
// Preserve and emit stack trace information even on hot paths.
// This may hurt performance, but also helps find flaky bugs.