From a9b91313cee629d81d4784798d03419fc7fa9e11 Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Wed, 17 Feb 2016 09:49:19 +0000 Subject: [PATCH] We also need to delete osr entries when deleting ArtMethod. In the unfortunate event an ArtMethod gets allocated at the same location as an old (deleted) ArtMethod, the osr_code_map_ lookup will succeed and return garbage. So we need to delete entries in the osr_code_map_ when an ArtMethod gets deleted. This should finally fix: dalvik.system.DexClassLoaderTest#test_twoJar_diff_getResourceAsStream Change-Id: I7c8b775c3376a6cfcb907f09b783e393967ad82d --- runtime/jit/jit_code_cache.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc index 9111ddf9f..fc89bfd9b 100644 --- a/runtime/jit/jit_code_cache.cc +++ b/runtime/jit/jit_code_cache.cc @@ -269,6 +269,14 @@ void JitCodeCache::RemoveMethodsIn(Thread* self, const LinearAlloc& alloc) { } } } + for (auto it = osr_code_map_.begin(); it != osr_code_map_.end();) { + if (alloc.ContainsUnsafe(it->first)) { + // Note that the code has already been removed in the loop above. + it = osr_code_map_.erase(it); + } else { + ++it; + } + } for (auto it = profiling_infos_.begin(); it != profiling_infos_.end();) { ProfilingInfo* info = *it; if (alloc.ContainsUnsafe(info->GetMethod())) { -- 2.11.0