This is an archive of the discontinued LLVM Phabricator instance.

Delete temp file if rename fails
ClosedPublic

Authored by rafael on Dec 4 2017, 3:34 PM.

Details

Reviewers
rnk
jhenderson
Summary

James noticed that when lld failed to replace the output file it would leave the temporary behind. The problem is that the existing logic is

  • cancel the delete flag
  • rename

We have to cancel first to avoid renaming and then crashing and deleting the old version. What is missing then is deleting the temporary file if the rename fails.

This can be an issue on both unix and windows, but I am not sure how to cause the rename to fail reliably on unix. I think it can be done on ZFS since it has an ACL system similar to what windows uses, but adding support for checking that in llvm-lit is probably not worth it.

Diff Detail

Event Timeline

rafael created this revision.Dec 4 2017, 3:34 PM
jhenderson accepted this revision.Dec 5 2017, 2:22 AM

LGTM. I confirmed that it works for the case I saw with LLD too.

Is there a particular reason why you're using icacls instead of chmod (available in the GnuWin32 tools) for the test? I'd say it's more familiar to most people, but I'm not bothered either way.

This revision is now accepted and ready to land.Dec 5 2017, 2:22 AM