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

Recursive references crash the game, prevent print() output and reaching breakpoints for whole code blocks. #1289

Closed
ScyDev opened this issue Jan 21, 2015 · 13 comments

Comments

@ScyDev
Copy link
Contributor

ScyDev commented Jan 21, 2015

I made a simple demo for this problem:
https://github.com/ScyDev/godot/tree/master/demos/crashes/recursive_reference_print_crash


Godot says "Process being debugged exited." before a breakpoint at the beginning of the loop is reached.

Update: It appears that the breakpoint is reached, because it influences the print() output. But I can't actually debug because of "Process being debugged exited".

godot -d says:

line index: 2 line: (crossed:False), (end:4.226463,-4.558409), (intersects:), (start:6.399961,-4.559154)
no intersect. adding line: (crossed:False), (end:4.226463,-4.558409), (intersects:), (start:6.399961,-4.559154)
mergedLines 1
indexOne 3 startIndex 2
line index: 3 line: (crossed:False), (end:4.225718,-6.731907), (intersects:), (start:4.226463,-4.558409)
no intersect. adding line: (crossed:False), (end:4.225718,-6.731907), (intersects:), (start:4.226463,-4.558409)
mergedLines 2
indexOne 4 startIndex 2
CLOSING CONNECTION
ERROR: set_stream_peer: Condition ' p_peer.is_null() ' is true.
   At: core/io/packet_peer.cpp:228.
@ScyDev
Copy link
Contributor Author

ScyDev commented Jan 22, 2015

The offending line seems to be:

print("line index: ",indexOne," line: ",currLine)

I kid you not. This crashes the game and prevents the debugger from ever reaching that code block.

These variations also do it:

        print("test "+str(currPoly))
        print("test ",currPoly[indexOne])
        print("test ",currLine)

@ScyDev
Copy link
Contributor Author

ScyDev commented Jan 22, 2015

Another day another insight:

The actual cause is that currLine is a dictionary which contains values that can reference back to currLine, thus creating a recursive reference. This crashes the game when trying to print() it.

@ScyDev ScyDev changed the title No breakpoint stepping in endless loops? Recursive references crash the game, prevent print() output and reaching breakpoints for whole code blocks. Jan 23, 2015
@bojidar-bg
Copy link
Contributor

Maybe we should just enforce some maximum depth when stringifying a dictionary?

@akien-mga
Copy link
Member

First of all thank you for your report and sorry for the delay.

We released Godot 3.0 in January 2018 after 18 months of work, fixing many old issues either directly, or by obsoleting/replacing the features they were referring to.

We still have hundreds of issues whose relevance/reproducibility needs to be checked against the current stable version, and that's where you can help us.
Could you check if the issue that you described initially is still relevant/reproducible in Godot 3.0 or any newer version, and comment about it here?

For bug reports, please also make sure that the issue contains detailed steps to reproduce the bug and, if possible, a zipped project that can be used to reproduce it right away. This greatly speeds up debugging and bugfixing tasks for our contributors.

Our Bugsquad will review this issue more in-depth in 15 days, and potentially close it if its relevance could not be confirmed.

Thanks in advance.

Note: This message is being copy-pasted to many "stale" issues (90+ days without activity). It might happen that it is not meaningful for this specific issue or appears oblivious of the issue's context, if so please comment to notify the Bugsquad about it.

@Piet-G
Copy link
Contributor

Piet-G commented Sep 16, 2018

Seems to be the same issue as #8693

@Chaosus
Copy link
Member

Chaosus commented Sep 16, 2018

It seems to be, but #8693 was created far recently + the title here is better describe the problem.. instead I close #8693, and re-assign @reduz to this issue

@Zireael07
Copy link
Contributor

Judging by #29088, it's still an issue. We could really use a warning for such situations, just to make finding them easier (I am starting to suspect I managed to fall victim to the same sort of a thing...)

@aaronfranke
Copy link
Member

Could someone made a minimal reproduction project that works with Godot 3.2? @ScyDev The linked project in the OP is very old, it uses an engine.cfg. Also, maybe bump to 4.0 milestone.

@Anutrix
Copy link
Contributor

Anutrix commented Apr 8, 2020

It seems that this issue can be broken into separate issues of which maybe one is fixed.
Also, like aaronfranke said, it would be nice if someone could make a new MRP for 3.2 or 4.0.

@akien-mga
Copy link
Member

The MRP from #8693 can be used in 3.x and master: hasharray.zip

Both still crash with infinite recursion, as expected from the code:

extends Node

func _ready():
	var arr = []
	arr.append(arr)
	print(arr.hash())

@TechnoPorg
Copy link
Contributor

This doesn't crash Godot for me on current master, using Akien's sample code. It does print the following error, though:

_ready: Max recursion reached
  <C++ Source>   core\variant\array.cpp:167 @ Array::recursive_hash()
  <Stack Trace>  Node2D.gd:15 @ _ready()

@akien-mga
Copy link
Member

Indeed, we added a check to detect this type of infinite recursion and abort.

@Calinou
Copy link
Member

Calinou commented Apr 25, 2022

For reference, recursion checks were added in #35816 (master) and #42625 (3.x).

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

No branches or pull requests