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

Setting a writeable suffix of an active ManeuverNode causes NullReferenceException #1868

Closed
MaxRebo1 opened this issue Nov 18, 2016 · 1 comment
Assignees

Comments

@MaxRebo1
Copy link

MaxRebo1 commented Nov 18, 2016

In KSP v1.2.1, using kOS version 1.0.2-pre-2, setting a settable suffix of aManeuverNodethat has been added to the flight plan causes aNullReferenceException.

Example code demonstrating this behavior - mvrtest.ks:

SET nd TO NODE(TIME:SECONDS+300,1,1,1).
ADD nd.
SET nd:ETA TO 600.

Exemplary log excerpt:

[LOG 13:05:05.592] kOS: At 1:/mvrtest, line 3
SET nd:ETA TO 600.
                       ^
[LOG 13:05:05.594] System.NullReferenceException: Object reference not set to an instance of an object
  at ManeuverNode.OnGizmoUpdated (Vector3d dV, Double ut) [0x00000] in <filename unknown>:0 
  at kOS.Suffixed.Node.ToNodeRef () [0x00000] in <filename unknown>:0 
  at kOS.Suffixed.Node.<InitializeSuffixes>b__12_1 (kOS.Safe.Encapsulation.ScalarValue value) [0x00000] in <filename unknown>:0 
  at kOS.Safe.Encapsulation.Suffixes.SetSuffix`1[kOS.Safe.Encapsulation.ScalarValue].Set (System.Object value) [0x00000] in <filename unknown>:0 
  at kOS.Safe.Encapsulation.Structure.ProcessSetSuffix (IDictionary`2 suffixes, System.String suffixName, System.Object value) [0x00000] in <filename unknown>:0 
  at kOS.Safe.Encapsulation.Structure.SetSuffix (System.String suffixName, System.Object value) [0x00000] in <filename unknown>:0 
  at kOS.Safe.Compilation.OpcodeSetMember.Execute (ICpu cpu) [0x00000] in <filename unknown>:0 
  at kOS.Safe.Execution.CPU.ExecuteInstruction (IProgramContext context, Boolean doProfiling) [0x00000] in <filename unknown>:0 
[LOG 13:05:05.599] Code Fragment
File                 Line:Col IP   label   opcode operand
====                 ====:=== ==== ================================  
                        0:0   0000         jump +27 
[built-in]              0:0   0001 @LR00   pushscope -999 0 
[built-in]              0:0   0002 @LR01   push $runonce 
[built-in]              0:0   0003 @LR02   swap 
[built-in]              0:0   0004 @LR03   storelocal 
[built-in]              0:0   0005 @LR04   push $filename 
[built-in]              0:0   0006 @LR05   swap 
[built-in]              0:0   0007 @LR06   storelocal 
[built-in]              0:0   0008 @LR07   push _KOSArgMarker_ 
[built-in]              0:0   0009 @LR08   push $filename 
[built-in]              0:0   0010 @LR09   eval 
[built-in]              0:0   0011 @LR10   push True 
[built-in]              0:0   0012 @LR11   push null 
[built-in]              0:0   0013 @LR12   call load() 
[built-in]              0:0   0014 @LR13   br.false +6 
[built-in]              0:0   0015 @LR14   push $runonce 
[built-in]              0:0   0016 @LR15   br.false +4 
[built-in]              0:0   0017 @LR16   pop 
[built-in]              0:0   0018 @LR17   push 0 
[built-in]              0:0   0019 @LR18   return 1 deep 
[built-in]              0:0   0020 @LR19   push $entrypoint 
[built-in]              0:0   0021 @LR20   swap 
[built-in]              0:0   0022 @LR21   storelocal 
[built-in]              0:0   0023 @LR22   call $entrypoint 
[built-in]              0:0   0024 @LR23   pop 
[built-in]              0:0   0025 @LR24   push 0 
[built-in]              0:0   0026 @LR25   return 1 deep 
1:/mvrtest              1:1   0027 @0001   argbottom 
1:/mvrtest              1:5   0028 @0002   push $nd 
1:/mvrtest              1:15  0029 @0003   push _KOSArgMarker_ 
1:/mvrtest              1:16  0030 @0004   push $time 
1:/mvrtest              1:21  0031 @0005   push seconds 
1:/mvrtest              1:21  0032 @0006   getmember 
1:/mvrtest              1:29  0033 @0007   push 300 
1:/mvrtest              1:28  0034 @0008   add 
1:/mvrtest              1:33  0035 @0009   push 1 
1:/mvrtest              1:35  0036 @0010   push 1 
1:/mvrtest              1:37  0037 @0011   push 1 
1:/mvrtest              1:37  0038 @0012   call node() 
1:/mvrtest              1:37  0039 @0013   store 
1:/mvrtest              2:1   0040 @0014   push _KOSArgMarker_ 
1:/mvrtest              2:5   0041 @0015   push $nd 
1:/mvrtest              2:5   0042 @0016   call add() 
1:/mvrtest              2:5   0043 @0017   pop 
1:/mvrtest              3:5   0044 @0018   push $nd 
1:/mvrtest              3:8   0045 @0019   push eta 
1:/mvrtest              3:15  0046 @0020   push 600 
1:/mvrtest              3:15  0047 @0021   setmember <<--INSTRUCTION POINTER--
                        0:0   0048         pop 
                        0:0   0049         EOP

Attached save file kOS.zip has a vessel called "kOS Tester" in orbit, which has the mvrtest.ks from above loaded on the local volume of its sole CPU.

@hvacengi hvacengi self-assigned this Nov 18, 2016
@hvacengi
Copy link
Member

I have a fix for this prepared and will submit it tonight.

hvacengi added a commit to hvacengi/KOS that referenced this issue Nov 23, 2016
Fixes KSP-KOS#1868

Node.cs
* Copy the logic from OnGizmoUpdated, excluding the two calls to
attachedGizmo
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

2 participants