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

IndexOutOfRangeException #24

Closed
joelmeaders opened this issue May 2, 2020 · 6 comments
Closed

IndexOutOfRangeException #24

joelmeaders opened this issue May 2, 2020 · 6 comments
Assignees
Labels

Comments

@joelmeaders
Copy link

Background

Astrogator version: 0.10.0

KSP version: 1.9.1.2788

Operating system: Win 10 Pro x62 1909 Build 18363.778

Planet packs installed: None

Save file: Not included

Problem

I realize this one won't be easily reproduced but I am getting a hard crash in KSP, log exceptions below.

I have multiple landed vessels within the same scenes (within 50km). Some with no engines and some with engines. When switching between them I get the crash without Astrogator GUI being open or used since game launch.

[EXC 12:30:19.853] IndexOutOfRangeException: index + length > size
	System.Array.Clear (System.Array array, System.Int32 index, System.Int32 length) (at <ad04dee02e7e4a85a1299c7ee81c79f6>:0)
	System.Collections.Generic.List`1[T].Clear () (at <ad04dee02e7e4a85a1299c7ee81c79f6>:0)
	PatchedConicSolver.RemoveManeuverNode (ManeuverNode node) (at <55ba45dc3a43403382024deac8dcd0be>:0)
	ManeuverNode.RemoveSelf () (at <55ba45dc3a43403382024deac8dcd0be>:0)
	Astrogator.KerbalTools.ClearManeuverNodes () (at <b33fb97694854c07a2d9d7891fb234c3>:0)
	Astrogator.AstrogationLoadBehaviorette.RecalculatePlaneChanges () (at <b33fb97694854c07a2d9d7891fb234c3>:0)
	Astrogator.AstrogationLoadBehaviorette.ThreadStart (ITargetable newOrigin, Astrogator.AstrogationLoadBehaviorette+LoadDoneCallback partialLoaded, Astrogator.AstrogationLoadBehaviorette+LoadDoneCallback fullyLoaded, Astrogator.AstrogationLoadBehaviorette+LoadDoneCallback aborted) (at <b33fb97694854c07a2d9d7891fb234c3>:0)
	Astrogator.AstrogationLoadBehaviorette+<>c__DisplayClass33_0.<TryStartLoad>b__0 () (at <b33fb97694854c07a2d9d7891fb234c3>:0)
	System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) (at <ad04dee02e7e4a85a1299c7ee81c79f6>:0)
	System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) (at <ad04dee02e7e4a85a1299c7ee81c79f6>:0)
	System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) (at <ad04dee02e7e4a85a1299c7ee81c79f6>:0)
	System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) (at <ad04dee02e7e4a85a1299c7ee81c79f6>:0)
	System.Threading.ThreadHelper.ThreadStart () (at <ad04dee02e7e4a85a1299c7ee81c79f6>:0)
	UnityEngine.DebugLogHandler:LogException(Exception, Object)
	ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
	UnityEngine.UnhandledExceptionHandler:<RegisterUECatcher>m__0(Object, UnhandledExceptionEventArgs)
[EXC 12:30:19.857] IndexOutOfRangeException: index + length > size
	System.Array.Clear (System.Array array, System.Int32 index, System.Int32 length) (at <ad04dee02e7e4a85a1299c7ee81c79f6>:0)
	System.Collections.Generic.List`1[T].Clear () (at <ad04dee02e7e4a85a1299c7ee81c79f6>:0)
	PatchedConicSolver.RemoveManeuverNode (ManeuverNode node) (at <55ba45dc3a43403382024deac8dcd0be>:0)
	ManeuverNode.RemoveSelf () (at <55ba45dc3a43403382024deac8dcd0be>:0)
	Astrogator.KerbalTools.ClearManeuverNodes () (at <b33fb97694854c07a2d9d7891fb234c3>:0)
	Astrogator.AstrogationLoadBehaviorette.RecalculatePlaneChanges () (at <b33fb97694854c07a2d9d7891fb234c3>:0)
	Astrogator.AstrogationLoadBehaviorette.ThreadStart (ITargetable newOrigin, Astrogator.AstrogationLoadBehaviorette+LoadDoneCallback partialLoaded, Astrogator.AstrogationLoadBehaviorette+LoadDoneCallback fullyLoaded, Astrogator.AstrogationLoadBehaviorette+LoadDoneCallback aborted) (at <b33fb97694854c07a2d9d7891fb234c3>:0)
	Astrogator.AstrogationLoadBehaviorette+<>c__DisplayClass33_0.<TryStartLoad>b__0 () (at <b33fb97694854c07a2d9d7891fb234c3>:0)
	System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) (at <ad04dee02e7e4a85a1299c7ee81c79f6>:0)
	System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) (at <ad04dee02e7e4a85a1299c7ee81c79f6>:0)
	System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) (at <ad04dee02e7e4a85a1299c7ee81c79f6>:0)
	System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) (at <ad04dee02e7e4a85a1299c7ee81c79f6>:0)
	System.Threading.ThreadHelper.ThreadStart () (at <ad04dee02e7e4a85a1299c7ee81c79f6>:0)
	UnityEngine.DebugLogHandler:LogException(Exception, Object)
	ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
	UnityEngine.UnhandledExceptionHandler:<RegisterUECatcher>m__0(Object, UnhandledExceptionEventArgs)
[EXC 12:30:33.840] IndexOutOfRangeException: index + length > size
	System.Array.Clear (System.Array array, System.Int32 index, System.Int32 length) (at <ad04dee02e7e4a85a1299c7ee81c79f6>:0)
	System.Collections.Generic.List`1[T].Clear () (at <ad04dee02e7e4a85a1299c7ee81c79f6>:0)
	PatchedConicSolver.RemoveManeuverNode (ManeuverNode node) (at <55ba45dc3a43403382024deac8dcd0be>:0)
	ManeuverNode.RemoveSelf () (at <55ba45dc3a43403382024deac8dcd0be>:0)
	Astrogator.KerbalTools.ClearManeuverNodes () (at <b33fb97694854c07a2d9d7891fb234c3>:0)
	Astrogator.AstrogationLoadBehaviorette.RecalculatePlaneChanges () (at <b33fb97694854c07a2d9d7891fb234c3>:0)
	Astrogator.AstrogationLoadBehaviorette.ThreadStart (ITargetable newOrigin, Astrogator.AstrogationLoadBehaviorette+LoadDoneCallback partialLoaded, Astrogator.AstrogationLoadBehaviorette+LoadDoneCallback fullyLoaded, Astrogator.AstrogationLoadBehaviorette+LoadDoneCallback aborted) (at <b33fb97694854c07a2d9d7891fb234c3>:0)
	Astrogator.AstrogationLoadBehaviorette+<>c__DisplayClass33_0.<TryStartLoad>b__0 () (at <b33fb97694854c07a2d9d7891fb234c3>:0)
	System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) (at <ad04dee02e7e4a85a1299c7ee81c79f6>:0)
	System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) (at <ad04dee02e7e4a85a1299c7ee81c79f6>:0)
	System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) (at <ad04dee02e7e4a85a1299c7ee81c79f6>:0)
	System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) (at <ad04dee02e7e4a85a1299c7ee81c79f6>:0)
	System.Threading.ThreadHelper.ThreadStart () (at <ad04dee02e7e4a85a1299c7ee81c79f6>:0)
	UnityEngine.DebugLogHandler:LogException(Exception, Object)
	ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
	UnityEngine.UnhandledExceptionHandler:<RegisterUECatcher>m__0(Object, UnhandledExceptionEventArgs)
@HebaruSan
Copy link
Owner

Hilarious; the Astrogator code isn't using any indices, but still I get IndexOutOfRangeException.
I guess we can just catch it and ignore, since it probably means another thread cleared this list for us.

@joelmeaders
Copy link
Author

Haha. I have read the KSP code-base is "special".

@HebaruSan HebaruSan added the bug label May 10, 2020
@HebaruSan
Copy link
Owner

@joelmeaders, here is a test build that catches and ignores this exception. Would you mind trying it out to see whether the problem still happens, or whether any new problems appear?

@joelmeaders
Copy link
Author

I'll give it a shot tonight and report back. Thanks!

@joelmeaders
Copy link
Author

@HebaruSan everything seems good. The logs don't show any references to Astrogator after instantiation. I checked out two of the previous problem areas and switched between landed ships many times without issue.

I also sent a new craft up and Astrogator still calculated the course correctly (transfer to Jool). That didn't cause issues before but figured I'd try anyways.

Thanks for the response and the work!

@HebaruSan
Copy link
Owner

Fix released in v0.10.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants