Skip to content

Compiler crash on Windows with -index-store-path #8224

Closed
@z2oh

Description

@z2oh

When using -index-store-path, we occasionally see compiler crashes on Windows like:

<unknown>:0: error: failed writing record 'Windows.Media.AppRecording.h-178ZCD4YPC99X': could not access record 'C:\<snip>\build\debug\index\store\v5\records\9X\Windows.Media.AppRecording.h-178ZCD4YPC99X': permission denied

Some investigation has led me to the llvm::sys::fs::access function, which can sometimes erroneously fail when called with AccessMode::Exist. Despite the path existing, the call to GetFileAttributesW fails with ERROR_ACCESS_DENIED. This seems to be some kind of race, but I've been unable to reproduce the problem in isolation.

I've had some success in fixing the issue with something like:

if (Mode == AccessMode::Exist) {
  if (::PathFileExistsW(PathUtf16.begin())) {
    return std::error_code();
  } else {
    return errc::no_such_file_or_directory;
  }
}

which I believe matches the expected semantics of the function. With this patch, I've been unable to reproduce the index writing failure, but I'm still not sure what the root cause of the access denied failure is, which I feel should be well understood before submitting a patch.

I'm aware this particular function is not specific to the Apple's LLVM fork, but as the compiler crash is surfaced in Apple specific code (the diagnostic is reported here), I figured I'd check here first. If it's agreed that the issue is in fact in llvm::sys::fs::access as I suspect, I will file upstream.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions