diff options
| author | 2023-09-04 10:29:45 +0200 | |
|---|---|---|
| committer | 2023-09-05 13:18:46 +0000 | |
| commit | b01acbe6bf47e03894cac5cd433c84f81e8d3f5d (patch) | |
| tree | b448a3c35a2d7d4be8cad09e4b0309e867982bcc | |
| parent | 09e2c93fbfa821bf1c1db6dbc5293e6b4b1f680b (diff) | |
Workaround for double `DeleteLocalRef()`.
Test: m test-art-host-gtest
Bug: 298297411
Change-Id: I0c6fa1fa33cc571e341a4165d3864d4832e047c6
| -rw-r--r-- | runtime/jni/local_reference_table.cc | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/runtime/jni/local_reference_table.cc b/runtime/jni/local_reference_table.cc index 59c4e31ba1..15aaf5baa3 100644 --- a/runtime/jni/local_reference_table.cc +++ b/runtime/jni/local_reference_table.cc @@ -483,6 +483,13 @@ bool LocalReferenceTable::Remove(LRTSegmentState previous_state, IndirectRef ire } DCHECK_LT(entry_index, top_index); + // Workaround for double `DeleteLocalRef` bug. b/298297411 + if (entry->IsFree()) { + // In debug build or with CheckJNI enabled, we would have detected this above. + LOG(ERROR) << "App error: `DeleteLocalRef()` on already deleted local ref. b/298297411"; + return false; + } + // Prune the free entry list if a segment with holes was popped before the `Remove()` call. uint32_t first_free_index = GetFirstFreeIndex(); if (first_free_index != kFreeListEnd && first_free_index >= top_index) { |