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

Collection was modified in SdkResolverService.ResolveSdkUsingResolversWithPatternsFirst #11043

Open
KirillOsenkov opened this issue Nov 27, 2024 · 3 comments

Comments

@KirillOsenkov
Copy link
Member

System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
   at bool System.Collections.Generic.List<T>+Enumerator.MoveNextRare()
   at SdkResult Microsoft.Build.BackEnd.SdkResolution.SdkResolverService.ResolveSdkUsingResolversWithPatternsFirst(int submissionId, SdkReference sdk, LoggingContext loggingContext, ElementLocation sdkReferenceLocation, string solutionPath, string projectPath, bool interactive, bool isRunningInVisualStudio, bool failOnUnresolvedSdk)
   at SdkResult Microsoft.Build.BackEnd.SdkResolution.CachingSdkResolverService.ResolveSdk(int submissionId, SdkReference sdk, LoggingContext loggingContext, ElementLocation sdkReferenceLocation, string solutionPath, string projectPath, bool interactive, bool isRunningInVisualStudio, bool failOnUnresolvedSdk)
   at void Microsoft.Build.Evaluation.Evaluator<P, I, M, D>.ExpandAndLoadImportsFromUnescapedImportExpressionConditioned(string directoryOfImportingFile, ProjectImportElement importElement, out List<ProjectRootElement> projects, out SdkResult sdkResult)
   at List<ProjectRootElement> Microsoft.Build.Evaluation.Evaluator<P, I, M, D>.ExpandAndLoadImports(string directoryOfImportingFile, ProjectImportElement importElement, out SdkResult sdkResult)
   at void Microsoft.Build.Evaluation.Evaluator<P, I, M, D>.EvaluateImportElement(string directoryOfImportingFile, ProjectImportElement importElement)
   at void Microsoft.Build.Evaluation.Evaluator<P, I, M, D>.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
   at void Microsoft.Build.Evaluation.Evaluator<P, I, M, D>.Evaluate() x 2
   at void Microsoft.Build.Evaluation.Project+ProjectImpl.Reevaluate(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
   at void Microsoft.Build.Evaluation.Project+ProjectImpl.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext) x 2
   at void Microsoft.Build.Evaluation.Project+ProjectImpl.Initialize(IDictionary<string, string> globalProperties, string toolsVersion, string subToolsetVersion, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext, bool interactive)
   at new Microsoft.Build.Evaluation.Project(string projectFile, IDictionary<string, string> globalProperties, string toolsVersion, string subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext, IDirectoryCacheFactory directoryCacheFactory, bool interactive)
   at Project Microsoft.Build.Evaluation.Project.FromFile(string file, ProjectOptions options)

just randomly saw this during project evaluation

@KirillOsenkov
Copy link
Member Author

Does this need a ToArray()?

foreach (SdkResolverManifest manifest in _specificResolversManifestsRegistry)

Looks like there's some weird recursion going on, need to ensure we protect against reentrancy

@KirillOsenkov
Copy link
Member Author

@AR-May

@KirillOsenkov
Copy link
Member Author

or could it be because of parallelism, when multiple project evaluations on multiple threads call into the SDK resolution?

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

No branches or pull requests

1 participant