System.InvalidOperationException: Collection was modified; enumeration operation may not execute. (Bug #282)

Added by Hwee Miin Koh about 4 years ago. Updated about 4 years ago.

Status:Closed Start date:07/01/2013
Priority:Low Due date:
Assignee:- % Done:


Category:Task Spent time: -
Target version:1.8.4
Affected version:1.8.0


Run the attached sample configuration non-stop for 3 days, following exception will happen:
System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
at System.Collections.Generic.List`1.Enumerator.MoveNext()
at ThoughtWorks.CruiseControl.Core.Util.BuildProgressInformation.GetQueueDataAsXml() in D:\work\gro\main\tools\Build\Tools\CCNet\project\core\util\BuildProgressInformation.cs:line 173
at ThoughtWorks.CruiseControl.Core.Util.BuildProgressInformation.SignalStartRunTask(String information) in D:\work\gro\main\tools\Build\Tools\CCNet\project\core\util\BuildProgressInformation.cs:line 65
at ThoughtWorks.CruiseControl.Core.Tasks.ConditionalTask.Execute(IIntegrationResult result) in D:\work\gro\main\tools\Build\Tools\CCNet\project\core\tasks\ConditionalTask.cs:line 190
at ThoughtWorks.CruiseControl.Core.Tasks.TaskBase.Run(IIntegrationResult result) in D:\work\gro\main\tools\Build\Tools\CCNet\project\core\tasks\TaskBase.cs:line 140
at ThoughtWorks.CruiseControl.Core.Project.RunTask(ITask task, IIntegrationResult result, Boolean isPublisher) in D:\work\gro\main\tools\Build\Tools\CCNet\project\core\Project.cs:line 1099
at ThoughtWorks.CruiseControl.Core.Project.RunTasks(IIntegrationResult result, IList tasksToRun, Dictionary`2 parameterValues) in D:\work\gro\main\tools\Build\Tools\CCNet\project\core\Project.cs:line 911
at ThoughtWorks.CruiseControl.Core.Project.Run(IIntegrationResult result, Dictionary`2 parameterValues) in D:\work\gro\main\tools\Build\Tools\CCNet\project\core\Project.cs:line 898
at ThoughtWorks.CruiseControl.Core.Project.Run(IIntegrationResult result) in D:\work\gro\main\tools\Build\Tools\CCNet\project\core\Project.cs:line 887
at ThoughtWorks.CruiseControl.Core.IntegrationRunner.Build(IIntegrationResult result) in D:\work\gro\main\tools\Build\Tools\CCNet\project\core\IntegrationRunner.cs:line 248
at ThoughtWorks.CruiseControl.Core.IntegrationRunner.Integrate(IntegrationRequest request) in D:\work\gro\main\tools\Build\Tools\CCNet\project\core\IntegrationRunner.cs:line 132

This is because ParallelTask is changing BuildProgressInformation.Progress through UpdateStartupInformation() without acquiring lock.

ccnet.config - sample configuration to reproduce the error (3.6 kB) Hwee Miin Koh, 07/01/2013 06:35 am


Updated by Hwee Miin Koh about 4 years ago

A possible fix would be acquire lock in BuildProgressInformation::UpdateStartupInformation():

public void UpdateStartupInformation(string information) {
lock (lockObject) {
Progress [0] = new BuildProgressInformationData(information);

Updated by Ruben Willems about 4 years ago

did you use CCNet 1.8.0 ?
if so, upgrade to 1.8.3 or later, because there was a bug fixed in the paralleltask concerning this part of the code.
see issue #173

  • Status changed from New to Feedback
  • Assignee set to Hwee Miin Koh
  • Target version set to 1.8.4

Updated by Hwee Miin Koh about 4 years ago

Yes, I've noticed that fix, even though I didn't upgrade to 1.8.3, but I apply that fix on 1.8.0 manually. Besides, this is a different issue, #173 is about NullReferenceException, this one is InvalidOperationException at different location.

Updated by Ruben Willems about 4 years ago

I think this is also fixed by your other patch of issue #283
But since all other public methods also set a lock, I'll update it for safety.

Updated by Ruben Willems about 4 years ago

  • Status changed from Feedback to Closed
  • Assignee deleted (Hwee Miin Koh)

Also available in: Atom PDF