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
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc
index 9111ddf..fc89bfd 100644
--- a/runtime/jit/jit_code_cache.cc
+++ b/runtime/jit/jit_code_cache.cc
@@ -269,6 +269,14 @@
}
}
}
+ 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())) {