linuxgurugamer / CivilianPopulation

Other
3 stars 4 forks source link

Invalid Operation Exception - Modifying a collection during iteration #3

Closed Chronovore closed 3 years ago

Chronovore commented 3 years ago

While looking for the cause of Kerbals dying when entering a vessel, I came across this exception in the logs. I can provide log file on request, it is 31MB - too large to attach.

[EXC 22:06:08.507] InvalidOperationException: Collection was modified; enumeration operation may not execute. System.ThrowHelper.ThrowInvalidOperationException (System.ExceptionResource resource) (at :0) System.Collections.Generic.List1+Enumerator[T].MoveNextRare () (at <ad04dee02e7e4a85a1299c7ee81c79f6>:0) System.Collections.Generic.List1+Enumerator[T].MoveNext () (at :0) CivilianPopulation.Infra.CivilianPopulationService.KillKerbals (CivilianPopulation.Domain.Repository.CivPopRepository repo, Vessel vessel) (at <5d0958d94aa24784af5d930bf9994638>:0) CivilianPopulation.Infra.CivilianPopulationModule+c__Iterator0.MoveNext () (at <5d0958d94aa24784af5d930bf9994638>:0) UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <5aeafee3fea24f37abd1315553f2cfa6>:0) UnityEngine.DebugLogHandler:LogException(Exception, Object) ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object) UnityEngine.Debug:CallOverridenDebugHandler(Exception, Object)

This is the area that seems suspect - modifying the crew while iterating the crew on that part https://github.com/linuxgurugamer/CivilianPopulation/blob/36a4a995d5e1c8ed79e521cf724f23449b4e0a7a/CivilianPopulation/Infra/CivilianPopulationService.cs#L69

rkunze commented 3 years ago

Same problem here, see https://forum.kerbalspaceprogram.com/index.php?/topic/191409-18x-19x-110x-civilian-population-modernized/&do=findComment&comment=3893134 for a report (should have looked into the Github issues before posting to the forum...)

linuxgurugamer commented 3 years ago

Try this beta please: https://www.dropbox.com/s/ochmvlw16i3ky58/CivilianPopulation-1.8.0-3.0.1.1.zip?dl=0

rkunze commented 3 years ago

Seems to help (see also https://forum.kerbalspaceprogram.com/index.php?/topic/191409-18x-19x-110x-civilian-population-modernized/&do=findComment&comment=3895583).

Thanks a lot!

linuxgurugamer commented 3 years ago

As in the problem is totally fixed, or is something else still happening?

rkunze commented 3 years ago

As far as I can see, the problem is fixed: I did 20 EVA/boarding cycles on a modded game (where Kerbals died almost every time on boarding with the previous version) without any problems.

Chronovore commented 3 years ago

Yes, confirmed it seems to be working for me. Closing.