Self-Connected Loops Completely Crash Resonite.
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
LoopStartoutput to the*input. - Connect the
LoopIterationoutput 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:
FornodeWhilenodeRange LoopnodeAsync FornodeAsync WhilenodeAsync Range Loopnode
With any node brought out, connect the following wires like this:
- Connect the
LoopEndoutput to the*input - Connect the
LoopStartoutput to the*input AND/OR connect theLoopInterationoutput 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:
When connecting a loop node like this (or when following the reproduction steps), it will crash Resonite:
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
OnLoadedevent), 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
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.
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
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.