Skip to content

tests: Fix module loading prefer-serialized test failure on Windows #65955

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 17, 2023

Conversation

compnerd
Copy link
Member

Fixes three tests failing on Windows:

  Swift(windows-x86_64) :: ModuleInterface/ModuleCache/force-module-loading-mode-archs.swift
  Swift(windows-x86_64) :: ModuleInterface/ModuleCache/force-module-loading-mode-framework.swift
  Swift(windows-x86_64) :: ModuleInterface/ModuleCache/force-module-loading-mode.swift

These test cases remove read access to the .swiftmodule . The expected behavior is that the compiler checks fs.exists("path-to.swiftmodule") , determines that the file exists and chooses to use it instead of the .swiftinterface. Compilation then fails because the file cannot be read.

https://github.com/apple/swift/blob/e22cf2e993267639ad8875707cadf401eb97d98b/lib/Frontend/ModuleInterfaceLoader.cpp#L752

On Windows, we were denying R access, which is broader than only read access to file contents but also includes file attributes and permissions. This caused fs.exists to fail since it relies on fs.status, which could not open the file with CreateFileW. The fix is is to only deny RD - read data/list directory access.

Replace this paragraph with a description of your changes and rationale. Provide links to external references/discussions if appropriate.

Resolves #NNNNN, fix apple/llvm-project#MMMMM.

Fixes three tests failing on Windows:

```
  Swift(windows-x86_64) :: ModuleInterface/ModuleCache/force-module-loading-mode-archs.swift
  Swift(windows-x86_64) :: ModuleInterface/ModuleCache/force-module-loading-mode-framework.swift
  Swift(windows-x86_64) :: ModuleInterface/ModuleCache/force-module-loading-mode.swift
```

These test cases remove read access to the `.swiftmodule` . The expected
behavior is that the compiler checks `fs.exists("path-to.swiftmodule")`
, determines that the file exists and chooses to use it instead of the
`.swiftinterface`. Compilation then fails because the file cannot be
read.

https://github.com/apple/swift/blob/e22cf2e993267639ad8875707cadf401eb97d98b/lib/Frontend/ModuleInterfaceLoader.cpp#L752

On Windows, we were denying `R` access, which is broader than only read
access to file contents but also includes file attributes and
permissions. This caused `fs.exists` to fail since it relies on
`fs.status`, which could not open the file with `CreateFileW`. The fix
is is to only deny `RD - read data/list directory` access.
@compnerd
Copy link
Member Author

@swift-ci please test

@tristanlabelle
Copy link
Contributor

Great job resolving that pesky #NNNNN! ;)

Copy link
Contributor

@tristanlabelle tristanlabelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Next time, I challenge you to make a fix with one less character.

@compnerd compnerd merged commit 9ca8a0e into swiftlang:main May 17, 2023
@compnerd compnerd deleted the denied branch May 17, 2023 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants