diff options
author | 2025-02-19 21:19:48 +0000 | |
---|---|---|
committer | 2025-02-19 23:24:15 +0000 | |
commit | ee712c170cdd7c25de63209705e574e653b8ef4e (patch) | |
tree | 2448551dfa0be5f1d9ddf1a0e9dcb9f31a98ee48 | |
parent | 50f41ab016288e44e70689d6ed60e38f749c59e2 (diff) |
Temporarily enable post-gc heap verification
This is to capture extra information for memory corruption crashes
observed with generational CMC. Since the crashes are mostly on x86_64
cuttlefish, we target only those.
The CL will be reverted within 1-2 days after few crash reports are
available.
Bug: 397381582
Test: ATP test-infra
Change-Id: I0de5d72a6cd8952c0524b3562e87cdf83e0c5be3
-rw-r--r-- | cmdline/cmdline_types.h | 4 | ||||
-rw-r--r-- | runtime/gc/collector/mark_compact.cc | 6 | ||||
-rw-r--r-- | runtime/runtime.cc | 5 |
3 files changed, 14 insertions, 1 deletions
diff --git a/cmdline/cmdline_types.h b/cmdline/cmdline_types.h index 524f181a8e..f2a96fa73f 100644 --- a/cmdline/cmdline_types.h +++ b/cmdline/cmdline_types.h @@ -553,7 +553,11 @@ struct XGcOption { bool verify_pre_gc_heap_ = kIsDebugBuild; bool verify_pre_sweeping_heap_ = kIsDebugBuild; bool generational_gc = kEnableGenerationalGCByDefault; +#if defined(__x86_64__) || defined(__i386__) + bool verify_post_gc_heap_ = true; +#else bool verify_post_gc_heap_ = kIsDebugBuild; +#endif bool verify_pre_gc_rosalloc_ = kIsDebugBuild; bool verify_pre_sweeping_rosalloc_ = false; bool verify_post_gc_rosalloc_ = false; diff --git a/runtime/gc/collector/mark_compact.cc b/runtime/gc/collector/mark_compact.cc index fafd8b55b4..cb314c5403 100644 --- a/runtime/gc/collector/mark_compact.cc +++ b/runtime/gc/collector/mark_compact.cc @@ -4824,6 +4824,12 @@ void MarkCompact::FinishPhase(bool performed_compaction) { compacting_ = false; marking_done_ = false; uint8_t* mark_bitmap_clear_end = black_dense_end_; + LOG(INFO) << " black_dense_end:" << static_cast<void*>(black_dense_end_) + << " mid_gen_end:" << static_cast<void*>(mid_gen_end_) + << " post_compact_end:" << static_cast<void*>(post_compact_end_) + << " black_allocations_begin:" << static_cast<void*>(black_allocations_begin_) + << " young:" << young_gen_ << " performed_compaction:" << performed_compaction; + // Retain values of some fields for logging in next GC cycle, in case there is // a memory corruption detected. prev_black_allocations_begin_ = static_cast<void*>(black_allocations_begin_); diff --git a/runtime/runtime.cc b/runtime/runtime.cc index 23e06ab792..a1b77743cf 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -1790,6 +1790,9 @@ bool Runtime::Init(RuntimeArgumentMap&& runtime_options_in) { (gUseUserfaultfd ? BackgroundGcOption(gc::kCollectorTypeCMCBackground) : runtime_options.GetOrDefault(Opt::BackgroundGc)); + bool verify_post_gc_heap = xgc_option.verify_post_gc_heap_ && + (android::base::GetProperty("ro.build.type", "") != "user"); + heap_ = new gc::Heap(runtime_options.GetOrDefault(Opt::MemoryInitialSize), runtime_options.GetOrDefault(Opt::HeapGrowthLimit), runtime_options.GetOrDefault(Opt::HeapMinFree), @@ -1822,7 +1825,7 @@ bool Runtime::Init(RuntimeArgumentMap&& runtime_options_in) { runtime_options.GetOrDefault(Opt::UseTLAB), xgc_option.verify_pre_gc_heap_, xgc_option.verify_pre_sweeping_heap_, - xgc_option.verify_post_gc_heap_, + verify_post_gc_heap, xgc_option.verify_pre_gc_rosalloc_, xgc_option.verify_pre_sweeping_rosalloc_, xgc_option.verify_post_gc_rosalloc_, |