[PATCH] D57960: [Support] Fix TempFile::discard to not leave behind temporary files

Andrew Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 8 09:45:47 PST 2019


andrewng created this revision.
andrewng added reviewers: ruiu, zturner, chandlerc.

If the first remove fails with ETXTBSY, attempt another remove after the
file has been closed.

This issue was seen when FileOutputBuffer falls back to an in memory
buffer due to the inability to mmap the on disk file. This occurred when
running LLD on an Ubuntu VM in VirtualBox on a Windows host attempting
to write the output to a VirtualBox shared folder.


https://reviews.llvm.org/D57960

Files:
  lib/Support/Path.cpp


Index: lib/Support/Path.cpp
===================================================================
--- lib/Support/Path.cpp
+++ lib/Support/Path.cpp
@@ -1147,6 +1147,14 @@
   }
   FD = -1;
 
+#ifndef _WIN32
+  if (RemoveEC.value() == ETXTBSY) {
+    RemoveEC = fs::remove(TmpName);
+    if (!RemoveEC)
+      TmpName = "";
+  }
+#endif
+
   return errorCodeToError(RemoveEC);
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57960.185991.patch
Type: text/x-patch
Size: 378 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190208/0705e80f/attachment.bin>


More information about the llvm-commits mailing list