Do backtrace collection while holding lock
Prevent cases where enough threads are doing backtraces at the same
time so that the system runs out of virtual address space, resulting
in std::bad_alloc.
Re-enabled test 708.
Test: test/testrunner/run_build_test_target.py art-jit-on-first-use-gcstress
Bug: 120112467
Change-Id: I291b9028880998aa33a53720dc2b3258ea7f3000
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index 8eebd12..4b63138 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -4006,10 +4006,10 @@
bool new_backtrace = false;
{
static constexpr size_t kMaxFrames = 16u;
+ MutexLock mu(self, *backtrace_lock_);
FixedSizeBacktrace<kMaxFrames> backtrace;
backtrace.Collect(/* skip_count= */ 2);
uint64_t hash = backtrace.Hash();
- MutexLock mu(self, *backtrace_lock_);
new_backtrace = seen_backtraces_.find(hash) == seen_backtraces_.end();
if (new_backtrace) {
seen_backtraces_.insert(hash);
diff --git a/test/knownfailures.json b/test/knownfailures.json
index e19ee3a..1e00c3f 100644
--- a/test/knownfailures.json
+++ b/test/knownfailures.json
@@ -1234,12 +1234,6 @@
"description": [ "Fails to eliminate dead reference when debuggable." ]
},
{
- "tests": ["708-jit-cache-churn"],
- "variant": "jit-on-first-use",
- "bug": "b/120112467",
- "description": [ "Fails on Android Build hosts with uncaught std::bad_alloc." ]
- },
- {
"tests": ["719-dm-verify-redefinition"],
"variant": "jvm | speed-profile | interp-ac | target | no-prebuild",
"description": ["Doesn't run on RI because of boot class redefintion.",