[stable] [SwiftPM] Fix concurrent directory/file/symlink creation crashes#187864
Conversation
…tter#186953) Robust SwiftPM symlink creation. Addresses potential race conditions during concurrent target builds where creating or cleaning up plugin symlinks might crash. - Check if symlink already exists and points to the correct target before deleting or recreating to prevent concurrency issues. - Clean up existing directories, files, or links properly using a switch expression. - Catch OS Error 17 (File exists) gracefully if another concurrent process creates the symlink at the same instant, and verify it points to the correct target. - Added 4 robust unit tests covering existing files, directories, broken symlinks, and concurrent creation failures. TAG=agy CONV=89884076-7f0a-4371-b5e1-6b4cae692891
|
This pull request was opened from and to a release candidate branch. This should only be done as part of the official Flutter release process. If you are attempting to make a regular contribution to the Flutter project, please close this PR and follow the instructions at Tree Hygiene for detailed instructions on contributing to Flutter. Reviewers: Use caution before merging pull requests to release branches. Ensure the proper procedure has been followed. |
There was a problem hiding this comment.
Code Review
This pull request enhances ErrorHandlingFileSystem to improve the robustness of file system operations, introducing retry logic for transient Windows locks, type-agnostic disk presence checks in deleteIfExists to handle broken symlinks, and wrapping additional asynchronous and synchronous operations. It also updates SwiftPackageManager to prevent parallel build race conditions during symlink creation. Feedback on the changes highlights a compilation error due to the use of unsupported leading dot shorthand syntax for enum values in Dart, and notes that the public member overrideWindowsRetryBackoffs is missing required documentation.
|
Linux analyze is failing with
But it did not complain on https://github.com/flutter/flutter/pull/186953/changes#diff-b0bd7898776cf9682ab468c8b86ad4c691d242364a058e0e5e31f64e40c6c050R846. Was this lint relaxed on master because of primary constructors? |
I'm not quite sure what happened here. There was a patch on master to fix this, but it wasn't flagged when the original PR landed (81742d2). I've made a minimal patch to this PR to fix the analysis error. I'll do the same for the beta CP PR as well. |
LongCatIsLooong
left a comment
There was a problem hiding this comment.
CPLGTM.
The new commit fix analysis failure only contains minimal changes to fix the an analyzer warning and shouldn't be an issue when merged back to master.
0700fc3
into
flutter:flutter-3.44-candidate.0
This pull request is created by automatic cherry pick workflow
Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request.
Issue Link:
#186953
Impact Description:
During concurrent target builds using SwiftPM, multiple processes might try to create or clean up plugin symlinks at the same time, leading to crashes (e.g., due to file already existing or being deleted while being accessed).
Changelog Description:
[flutter/186953] When building concurrently with SwiftPM [on macOS/iOS], fix crashes caused by concurrent directory/file/symlink creation.
Workaround:
Avoid concurrent builds, or disable SwiftPM if possible.
Risk:
What is the risk level of this cherry-pick?
Test Coverage:
Are you confident that your fix is well-tested by automated tests?
Validation Steps:
Run concurrent builds of a project using SwiftPM and verify that it no longer crashes during symlink creation.