<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">On Feb 27, 2013, at 4:42 PM, Aaron Ballman <<a href="mailto:aaron@aaronballman.com">aaron@aaronballman.com</a>> wrote:<br><div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;">Can we fall into the same trap in the Windows version of this code too?<br></div></blockquote><div><br></div><div>I don't have a windows machine to test.</div><div>For anyone interested, the way I tested the fix was like this:</div><div><br></div><div>$ mkdir temp</div><div>$ cd temp</div><div>$ touch empty.c</div><div>$ lldb -- /path/to/clang -cc1 empty.c -emit-pch -o empty.pch</div><div>(stop at the "rety_open_create:" label of unique_file function)</div><div><br></div><div>Now delete 'temp' directory and make sure the function does not get stuck.</div><div><br></div><div>-Argyrios</div><br><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"><br>~Aaron<br><br>On Wed, Feb 27, 2013 at 7:38 PM, Argyrios Kyrtzidis <<a href="mailto:akyrtzi@gmail.com">akyrtzi@gmail.com</a>> wrote:<br><blockquote type="cite">Author: akirtzidis<br>Date: Wed Feb 27 18:38:19 2013<br>New Revision: 176226<br><br>URL: <a href="http://llvm.org/viewvc/llvm-project?rev=176226&view=rev">http://llvm.org/viewvc/llvm-project?rev=176226&view=rev</a><br>Log:<br>[PathV2] In llvm::sys::fs::unique_file, make sure it doesn't fall into an infinite loop by constantly trying<br>to create the parent path.<br><br>This can happen if the path is a relative filename and the current directory was removed.<br>Thanks to Daniel D. for the hint in fixing it.<br><br>Modified:<br>   llvm/trunk/lib/Support/Unix/PathV2.inc<br><br>Modified: llvm/trunk/lib/Support/Unix/PathV2.inc<br>URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/PathV2.inc?rev=176226&r1=176225&r2=176226&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/PathV2.inc?rev=176226&r1=176225&r2=176226&view=diff</a><br>==============================================================================<br>--- llvm/trunk/lib/Support/Unix/PathV2.inc (original)<br>+++ llvm/trunk/lib/Support/Unix/PathV2.inc Wed Feb 27 18:38:19 2013<br>@@ -417,6 +417,10 @@ retry_random_path:<br>      RandomPath[i] = "0123456789abcdef"[sys::Process::GetRandomNumber() & 15];<br>  }<br><br>+  // Make sure we don't fall into an infinite loop by constantly trying<br>+  // to create the parent path.<br>+  bool TriedToCreateParent = false;<br>+<br>  // Try to open + create the file.<br>rety_open_create:<br>  int RandomFD = ::open(RandomPath.c_str(), O_RDWR | O_CREAT | O_EXCL, mode);<br>@@ -427,7 +431,9 @@ rety_open_create:<br>      goto retry_random_path;<br>    // If path prefix doesn't exist, try to create it.<br>    if (SavedErrno == errc::no_such_file_or_directory &&<br>-        !exists(path::parent_path(RandomPath))) {<br>+        !exists(path::parent_path(RandomPath)) &&<br>+        !TriedToCreateParent) {<br>+      TriedToCreateParent = true;<br>      StringRef p(RandomPath);<br>      SmallString<64> dir_to_create;<br>      for (path::const_iterator i = path::begin(p),<br><br><br>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</blockquote></div></blockquote></div><br></body></html>