Resonite-Issues icon indicating copy to clipboard operation
Resonite-Issues copied to clipboard

Self-Connected Loops Completely Crash Resonite.

Open AmasterAmaster opened this issue 1 year ago • 3 comments

Describe the bug?

I was just chilling in a world and a friend of mine saw a stray Range Loop node. I commented that it was unwise to connect it back on itself, but they did anyways. Nothing happened when they did the following things:

  • Connect the LoopStart output to the * input.
  • Connect the LoopIteration output to the * input

However, when they connected all of the outputs into the * input, Resonite crashed (infinite loop?). But... How???

Normally, nodes get red when connected like this, and even then, a pulse is needed to start the loop. So, unless I am unaware that connecting wires sends an impulse, this is a bug (which I am very sure this is).

Looking into this further, Async loops are not safe from this, as Resonite will freeze the same way, so this can't be an impulse, it has to be something else then...

To Reproduce

Spawn out any one of these nodes:

  • For node
  • While node
  • Range Loop node
  • Async For node
  • Async While node
  • Async Range Loop node

With any node brought out, connect the following wires like this:

  • Connect the LoopEnd output to the * input
  • Connect the LoopStart output to the * input AND/OR connect the LoopInteration output to the * input.

Resonite will crash completely after these wires are connected.

Expected behavior

Loop nodes that directly connect to themselves, should just turn red and/or stop the node group from working (or to fail gracefully).

Screenshots

This is what the nodes should do: Self-Connected Loops 02

When connecting a loop node like this (or when following the reproduction steps), it will crash Resonite: Self-Connected Loops 01

Resonite Version Number

Beta 2024.8.5.1341

What Platforms does this occur on?

Windows

What headset if any do you use?

Index & Desktop

Log Files

Here is the log file. As this is a complete crash, it just gets cut off at the end of the file. ANDREW-SUPERPC - 2024.8.5.1341 - 2024-08-10 15_24_34.log

Additional Context

From a search around GitHub, I found the following issues, along with my thoughts about them compared to this issue:

  • #1054 - This issue can't account for another node like 1054 can. As the connected wire is going directly into itself.
  • #774 & #1677 - At first, this looks like it may help, but I feel this is not the case. It freezes the entire application with no pulse sent to it
  • #2008 - If someone were to save a node (or even worse connect the nodes during an OnLoaded event), then 2008 looks like it might fix it. But I doubt it, as the nodes don't have a pulse to even start, and if someone were to attempt to connect the wires, they freeze anyways.

Reporters

AmasterAmaster

AmasterAmaster avatar Aug 10 '24 20:08 AmasterAmaster

This appears to be a duplicate to the linked issue #1677, @AmasterAmaster. At the moment there is no protection for infinitely executing node graphs in ProtoFlux, so creating a loop like this will cause this issue to occur. Thanks for the report.

LexiBasilisk avatar Aug 12 '24 00:08 LexiBasilisk

I don't think this is a duplicate as https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/1677 requires a call to happen, while OP states that this only requires connecting wires

TisFoolish avatar Aug 12 '24 00:08 TisFoolish

This loop arises in infinite recursion from ProtoFlux.Core.ImpulseValidator.ValidateImpulseFlow(). I describe an alternative implementation of this validation that fixes this issue in #1467.

yoshiyoshyosh avatar Nov 26 '25 11:11 yoshiyoshyosh