Yellow-Dog-Man / Resonite-Issues

Issue repository for Resonite.
https://resonite.com
139 stars 2 forks source link

NaN in ValueDisplay<decimal> Crashes World Entirely #2746

Open Majus-Dev opened 3 months ago

Majus-Dev commented 3 months ago

Describe the bug?

If you try to connect a decimal value of NaN into a ValueDisplay\<decimal> you get crashed out of the world.

If a decimal value, not NaN is connected into a ValueDisplay \<decimal> and the value changes value to NaN the world crashes entirely.

The easiest way to achieve NaN for decimal is using the ValueMod\<decimal> node and setting the bottom input value to 0.

Setting the input value into the bottom slot of a ValueMod\<decimal> to i.e. 0.1 will set the output value to 0, which allows you to connect the output of the ValueMod\<decimal > into the input of the ValueDisplay\<decimal>, then if you set the input value to the ValueMod\<decimal> the output value gets set to NaN and crashes the world. The crash also works on headless hosted worlds.

To Reproduce

  1. Spawn ValueMod\<decimal> node
  2. Add input with value 0.1 to bottom input
  3. Connect display to output of ValueMod\<decimal>
  4. Set the input to 0 or delete input entirely
  5. World crashes

Expected behavior

ValueDisplay\<decimal> should display NaN

Screenshots

First is a sanitized example in a flat grid alone straight after booting up (please excuse my english i am not natively english)

https://github.com/user-attachments/assets/263d1cd2-2c07-4623-9373-5d1ef17fd496

Second is when we crashed MrTumnus' headless world using the bug

https://github.com/user-attachments/assets/4e1cc61f-daf2-47ea-8f48-807fb4c1a650

Resonite Version Number

Beta 2024.8.5.1341

What Platforms does this occur on?

Windows

What headset if any do you use?

Desktop

Log Files

MAJUS - 2024.8.5.1341 - 2024-08-10 01_54_04.log

Additional Context

No response

Reporters

Julibugs Majus MrTumnus MIP_2000

shiftyscales commented 2 months ago

Relevant exception seems to be at line 1363.

1:56:05 AM.002 (165 FPS)    Unhandled Exception when updating world: Majus World. State Running, Refresh Stage: ProtoFluxDiscreteChangesPost, Init State: Finished, SyncTick 9353, StateVersion: 18706
Dumped world state to:
System.DivideByZeroException: Attempted to divide by zero.
  at (wrapper managed-to-native) System.Decimal.FCallDivide(System.Decimal&,System.Decimal&)
  at System.Decimal.op_Division (System.Decimal d1, System.Decimal d2) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Decimal.Remainder (System.Decimal d1, System.Decimal d2) [0x0006b] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Decimal.op_Modulus (System.Decimal d1, System.Decimal d2) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at Elements.Core.Coder`1+<>c[T].<.cctor>b__143_403 (System.Decimal a, System.Decimal b) [0x00000] in <0fc81716929342ceae57a0bf0dd62654>:0 
  at (wrapper delegate-invoke) Elements.Core.BiOperator`1[System.Decimal].invoke_E_E_E(System.Decimal,System.Decimal)
  at ProtoFlux.Runtimes.Execution.Nodes.Operators.ValueMod`1[T].Compute (ProtoFlux.Runtimes.Execution.ExecutionContext context) [0x00021] in <2c9c6937a5134551ad4fc9da42e8f767>:0 
  at ProtoFlux.Runtimes.Execution.ValueFunctionNode`2[C,T].Evaluate (C context) [0x00000] in <73d8ff99d53044acbb81bdc4e997e873>:0 
  at ProtoFlux.Runtimes.Execution.EvaluationSequence`1[C].Evaluate (C context) [0x00068] in <73d8ff99d53044acbb81bdc4e997e873>:0 
  at ProtoFlux.Runtimes.Execution.EvaluationSequence`1[C].EvaluateValue[T] (ProtoFlux.Core.IOutput output, C context) [0x00000] in <73d8ff99d53044acbb81bdc4e997e873>:0 
  at ProtoFlux.Runtimes.Execution.ExecutionRuntime`1[C].EvaluateValue[T] (ProtoFlux.Core.IOutput output, ProtoFlux.Runtimes.Execution.ExecutionContext context) [0x00083] in <73d8ff99d53044acbb81bdc4e997e873>:0 
  at ProtoFlux.Runtimes.Execution.ExecutionContextExtensions.Evaluate[T] (ProtoFlux.Core.ValueInput`1[T] input, ProtoFlux.Runtimes.Execution.ExecutionContext context, T defaultValue) [0x00018] in <73d8ff99d53044acbb81bdc4e997e873>:0 
  at ProtoFlux.Runtimes.Execution.Nodes.ExternalValueDisplay`2[C,T].Changed (C context) [0x00000] in <73d8ff99d53044acbb81bdc4e997e873>:0 
  at ProtoFlux.Runtimes.Execution.ExecutionChangesDispatcher`1[C].DispatchChanges (ProtoFlux.Runtimes.Execution.ExecutionRuntime`1[C] runtime, C context) [0x000d6] in <73d8ff99d53044acbb81bdc4e997e873>:0 
  at FrooxEngine.ProtoFlux.ProtoFluxNodeGroup.RunNodeChanges () [0x00108] in <fd56a75ff6ac403bbb6aeeaa7ec82c26>:0 
  at FrooxEngine.ProtoFlux.ProtoFluxController.RunDiscreteChanges () [0x0002f] in <fd56a75ff6ac403bbb6aeeaa7ec82c26>:0 
  at FrooxEngine.World.RefreshStep () [0x00434] in <fd56a75ff6ac403bbb6aeeaa7ec82c26>:0 
  at FrooxEngine.World.Refresh () [0x00073] in <fd56a75ff6ac403bbb6aeeaa7ec82c26>:0 
  at FrooxEngine.WorldManager.UpdateStep () [0x004a3] in <fd56a75ff6ac403bbb6aeeaa7ec82c26>:0 

  at System.Environment.get_StackTrace () [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at Elements.Core.UniLog.Error (System.String message, System.Boolean stackTrace) [0x00000] in <0fc81716929342ceae57a0bf0dd62654>:0 
  at FrooxEngine.WorldManager.UpdateStep () [0x00000] in <fd56a75ff6ac403bbb6aeeaa7ec82c26>:0 
  at FrooxEngine.WorldManager.RunUpdateLoop () [0x00000] in <fd56a75ff6ac403bbb6aeeaa7ec82c26>:0 
  at FrooxEngine.Engine.UpdateStep () [0x00000] in <fd56a75ff6ac403bbb6aeeaa7ec82c26>:0 
  at FrooxEngine.Engine.RunUpdateLoop () [0x00000] in <fd56a75ff6ac403bbb6aeeaa7ec82c26>:0 
  at UnityFrooxEngineRunner.FrooxEngineRunner.UpdateFrooxEngine () [0x00000] in <7c2e4430a1b44da9a9660b0b5f5b1914>:0 
  at UnityFrooxEngineRunner.FrooxEngineRunner.Update () [0x00000] in <7c2e4430a1b44da9a9660b0b5f5b1914>:0 
Frooxius commented 2 months ago

We can fix the exception and crash from happening, but we cannot make the display show NaN.

NaN values are supported by float and double datatypes, which follow the IEEE 574 standard. However decimal is a very different datatype, more specific to C#/CLR/.NET

Most importantly, decimal datatype does not support NaN - you cannot have such values with this datatype. I'm not sure what led you to believe that you're getting NaN values, but there's now way you can get those for decimal specifically.