OSDN Git Service

ART: Do not unlink unreadable ELF files
authorAndreas Gampe <agampe@google.com>
Tue, 16 Sep 2014 05:25:24 +0000 (22:25 -0700)
committerAndreas Gampe <agampe@google.com>
Tue, 16 Sep 2014 05:41:17 +0000 (22:41 -0700)
Unlinking can be racy with respect to secondary oat files.

Bug: 17496483

(cherry picked from commit 00503dad8139dcf7b7fc7986ace93e3e45198096)

Change-Id: I53f92a924b34dfcf50d7e02487c5f8f23de627ca

runtime/oat_file.cc

index 7375428..c621e88 100644 (file)
@@ -93,13 +93,9 @@ OatFile* OatFile::Open(const std::string& filename,
     }
     ret.reset(OpenElfFile(file.get(), location, requested_base, false, executable, error_msg));
 
-    // Opening the file failed. Try to delete it and maybe we have more luck after it gets
-    // regenerated.
-    if (ret.get() == nullptr) {
-      LOG(WARNING) << "Attempting to unlink oat file " << filename << " that could not be opened. "
-                   << "Error was: " << error_msg;
-      unlink(file->GetPath().c_str());  // Try to remove the file.
-    }
+    // It would be nice to unlink here. But we might have opened the file created by the
+    // ScopedLock, which we better not delete to avoid races. TODO: Investigate how to fix the API
+    // to allow removal when we know the ELF must be borked.
   }
   return ret.release();
 }