Skip to content
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

Resolve sandbox issues on external volumes #6773

Merged
merged 1 commit into from Aug 8, 2023

Conversation

neonichu
Copy link
Member

@neonichu neonichu commented Aug 2, 2023

The sandbox profile SwiftPM generates curates the directories plugins and manifests are able to write to. Several Foundation APIs use a so-called "item replacement directory" when doing atomic operations and this happens to be a special path on the same volume when performing operations on an external volume. This lead to those operations being blocked in plugins which does not seem right since those item replacement directories are temporary directories in spirit. We now automatically allow writes for those when generating a sandbox profile.

rdar://112217177

@neonichu neonichu self-assigned this Aug 2, 2023
@neonichu
Copy link
Member Author

neonichu commented Aug 2, 2023

apple/swift-tools-support-core#427
@swift-ci please smoke test

@neonichu
Copy link
Member Author

neonichu commented Aug 2, 2023

apple/swift-tools-support-core#427
@swift-ci please smoke test

@neonichu
Copy link
Member Author

neonichu commented Aug 2, 2023

@swift-ci please smoke test

@neonichu
Copy link
Member Author

neonichu commented Aug 2, 2023

Feels like we need a bot to re-run CI at this point...

@neonichu neonichu enabled auto-merge (squash) August 3, 2023 00:54
@neonichu
Copy link
Member Author

neonichu commented Aug 3, 2023

@swift-ci please smoke test

@neonichu
Copy link
Member Author

neonichu commented Aug 3, 2023

Swift CI is still broken for us

@MaxDesiatov
Copy link
Member

@swift-ci smoke test linux

@neonichu
Copy link
Member Author

neonichu commented Aug 4, 2023

@swift-ci please smoke test

@neonichu
Copy link
Member Author

neonichu commented Aug 4, 2023

@swift-ci please smoke test macOS

@MaxDesiatov
Copy link
Member

@swift-ci smoke test macos

@neonichu
Copy link
Member Author

neonichu commented Aug 7, 2023

Looks like this test failure must be caused by these changes:

Test Suite 'Selected tests' started at 2023-08-05 00:56:08.742Test Suite 'SourceKitLSPPackageTests.xctest' started at 2023-08-05 00:56:08.743Test Suite 'SwiftPMWorkspaceTests' started at 2023-08-05 00:56:08.743Test Case '-[SKSwiftPMWorkspaceTests.SwiftPMWorkspaceTests testNestedInvalidPackageSwift]' started.[2023-08-05 00:56:11.150] [warning]: failed loading cached manifest for 'pkg': Error Domain=NSCocoaErrorDomain Code=4 "The file “manifests” doesn’t exist." UserInfo={NSFilePath=/home/user/caches/org.swift.swiftpm/manifests, NSUnderlyingError=0x6000029d47b0 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}[2023-08-05 00:56:11.761] [warning]: failed closing cache: Error Domain=NSCocoaErrorDomain Code=4 "The file “manifests” doesn’t exist." UserInfo={NSFilePath=/home/user/caches/org.swift.swiftpm/manifests, NSUnderlyingError=0x6000029abed0 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}[2023-08-05 00:56:11.784] [error]: Error Domain=NSCocoaErrorDomain Code=4 "The file “manifests” doesn’t exist." UserInfo={NSURL=file:///home/user/caches/org.swift.swiftpm/manifests, NSUnderlyingError=0x6000029ab870 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}/Users/ec2-user/jenkins/workspace/swift-package-manager-PR-macos-smoke-test/branch-main/sourcekit-lsp/Sources/SKSwiftPMWorkspace/SwiftPMWorkspace.swift:187: error: -[SKSwiftPMWorkspaceTests.SwiftPMWorkspaceTests testNestedInvalidPackageSwift] : failed: caught error: "The package does not contain a buildable target. 
Add at least one `.target` or `.executableTarget` to your `Package.swift`."Test Case '-[SKSwiftPMWorkspaceTests.SwiftPMWorkspaceTests testNestedInvalidPackageSwift]' failed (8.904 seconds).Test Suite 'SwiftPMWorkspaceTests' failed at 2023-08-05 00:56:17.648.

The sandbox profile SwiftPM generates curates the directories plugins and manifests are able to write to. Several Foundation APIs use a so-called "item replacement directory" when doing atomic operations and this happens to be a special path on the same volume when performing operations on an external volume. This lead to those operations being blocked in plugins which does not seem right since those item replacement directories are temporary directories in spirit. We now automatically allow writes for those when generating a sandbox profile.

rdar://112217177
@neonichu neonichu force-pushed the fix-sandbox-on-external-volumes branch from a23d3c0 to ebf511b Compare August 8, 2023 20:59
@neonichu
Copy link
Member Author

neonichu commented Aug 8, 2023

Ah, figured out the issue now: we also generate a sandbox profile for manifest loading and that can happen with virtual paths of course for which determining the item replacement directory fails, but the error was caught at a higher level and lead to the confusing test outcome.

I changed this now to ignore any errors when determining the item replacement directories which resolves this but also seems like the correct behavior since those errors shouldn't be fatal.

@neonichu
Copy link
Member Author

neonichu commented Aug 8, 2023

@swift-ci please smoke test

@neonichu
Copy link
Member Author

neonichu commented Aug 8, 2023

@swift-ci please smoke test windows

@neonichu neonichu merged commit 8686504 into main Aug 8, 2023
5 checks passed
@neonichu neonichu deleted the fix-sandbox-on-external-volumes branch August 8, 2023 22:51
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.

None yet

2 participants