<div dir="ltr">It's surprising (at least, to me) to get "permission denied" when attempting GetFilePathNameByHandle. It seems more likely that the function failed to resolve the path for some other reason, and then the archiver tried to do an operation to the file with the unresolved path, and _that_ step caused the "permission denied."<div><br></div><div>But if it _is_ the GetFilePathNameByHandle, then I would guess that the file handle is corrupted thus the request is about an object the process doesn't have rights to access...<br><div><br></div><div>I don't have Windows 7 to try it out.</div><div><br></div><div>Does the file already exist? If not, is it being created? Is there anything unusual about the path (e.g., is it longer than 256-ish characters long or referencing a server over a network or contain characters outside of ASCII that are possibly in the wrong encoding)?<br><div><br></div><div>If you're able to debug it at the point of the GetFilePathNameByHandle call, can you check that the handle looks reasonable? It should look like a valid pointer (possibly just the lower 32-bits if you're on a 64-bit machine), so 0, 0xFFFFFFFF, and unaligned values would be suspicious.</div></div></div><div><br></div><div>Another common problem is that sometimes anti-malware scanners will briefly lock a newly created file to scan it, which can cause a sharing violation. Usually these are intermittent because they're timing sensitive, but it might be worth temporarily disabling your scanners to see if that makes the problem go away. If so, we can look at the access pattern and see if there's a less fragile approach.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 18, 2021 at 4:12 PM Snider, Todd via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div lang="EN-US">
<div class="gmail-m_2836700508167914082WordSection1">
<p class="MsoNormal">Hi All,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I’ve run into an issue trying to run an llvm-ar executable built on Windows 10 on a Windows 7 machine.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I get a permission denied error when the archiver tries to write the new archive file:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">%> llvm-ar rv mylib.lib foo.o<u></u><u></u></p>
<p class="MsoNormal">llvm-ar.exe: warning: creating mylib.lib<u></u><u></u></p>
<p class="MsoNormal">llvm-ar.exe: error: mylib.lib: permission denied<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I’ve tracked the issue down to a call to ::GetFinalPathByHandle() from realPathFromHandle() (defined in llvm/lib/Support/Windows/Path.inc).<u></u><u></u></p>
<p class="MsoNormal">realPathFromHandle() will set an error code when ::GetFinalPathByHandle() returns a value of 0 (as it does in the above case).<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Is there a known incompatibility/limitation/bug with trying to run the Windows 10 kernel version of GetFinalPathByHandle() on a Windows 7 machine?<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">~ Todd Snider<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>