OSDN Git Service

We also need to delete osr entries when deleting ArtMethod.
authorNicolas Geoffray <ngeoffray@google.com>
Wed, 17 Feb 2016 09:49:19 +0000 (09:49 +0000)
committerNicolas Geoffray <ngeoffray@google.com>
Wed, 17 Feb 2016 09:51:16 +0000 (09:51 +0000)
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

index 9111ddf..fc89bfd 100644 (file)
@@ -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())) {