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

Game crashes when debugging the project (infinite recursion after ScriptDebuggerRemote::_put_variable) #51049

Closed
sairam4123 opened this issue Jul 30, 2021 · 12 comments · Fixed by #51068

Comments

@sairam4123
Copy link

sairam4123 commented Jul 30, 2021

Godot version

3.3.2.stable

System information

Windows 10, Nvidia GeForce GTX 1050, 27.21.14.5771

Issue description

When running my game, my game crashes whenever I pause for debugging, no errors over in Godot Console, it seems to crash in Godot 3.3.2 stable, Godot 3.4 beta 1, Godot 3.4 beta 2.

Steps to reproduce

  1. Download my project
  2. Run the game
  3. Create any sort of structure and press T and click any node (road node, not Godot node).
  4. Pause with a error or a breakpoint (wait like around 10-15 secs)
  5. Observe the game crash.

Minimal reproduction project

CrashingGameWhenDebugging.zip

Video showcasing the crash:

3RUQ9Hy3Eb.mp4
@sairam4123 sairam4123 changed the title [Godot3.4beta1&2] [Godot3.4beta1&2] Game crashes when debugging the project Jul 30, 2021
@YuriSizov YuriSizov changed the title [Godot3.4beta1&2] Game crashes when debugging the project Game crashes when debugging the project Jul 30, 2021
@Torguen
Copy link

Torguen commented Jul 30, 2021

I think it would be good if you solved the problem that appears when loading the project so that others can do a test.
Captura

I also see that a lot of files are loaded, can't you minimize the project to the maximum or remove all unnecessary files?

@sairam4123
Copy link
Author

sairam4123 commented Jul 30, 2021

I had the same problem yesterday, it certainly went away after I did a restart. I guess that might be a problem.
I certainly have no idea what's causing it. Could you check plugin.gd?

@akien-mga
Copy link
Member

akien-mga commented Jul 30, 2021

The hterrain load error is normal, it always happens on the first import. Reopening the project solves it.

I can't reproduce the crash on Linux with 3.4 beta 2, I can set breakpoints and step through the code without issue.

it seems to crash in Godot 3.3.2 stable, Godot 3.4 beta 1, Godot 3.4 beta 2.

What was the last version that you used where it did not crash? (if any)

@sairam4123
Copy link
Author

sairam4123 commented Jul 30, 2021

What was the last version that you used where it did not crash? (if any)

Well.. in Godot 3.3.2, the game didn't crash before, but now it crashes sometimes. In 3.4 beta 2 it seems to crash everytime.

Here's a video showcasing it (3.4beta2)

04raZC9yju.mp4

(3.4beta1)

8kBPLsYPHa.mp4

Forgot to show logs
here's the picture
Godot_v3 4-beta1_win64_PLu0B4uNtc

(3.3.2 stable)

A37edgAYvJ.mp4

@akien-mga
Copy link
Member

That doesn't look like a crash, it's just a bug in your code and the execution stops, the debugger is raised and takes the focus to show you the error. Or does the game window get force closed too? It should only lose focus (i.e. the editor window takes focus, the game window is paused while the debugger is active).

@sairam4123
Copy link
Author

sairam4123 commented Jul 30, 2021

the game window gets force closed and the debugger stops after like around 5-10secs.

3RUQ9Hy3Eb.mp4

@akien-mga
Copy link
Member

How do you select the node at the end (white circle)?

@sairam4123

This comment has been minimized.

@akien-mga
Copy link
Member

So yeah if you run the game directly without the editor, you'll see errors spammed continuously whenever you trick to click a node after pressing T:

[[Reference:2068], [Reference:2070], [Reference:2179], [Reference:2187], [Reference:2189]]
SCRIPT ERROR: Invalid get index '[[Reference:1983], [Reference:2066]]' (on base: 'Dictionary').
          at: RoadNetwork.disconnect_intersections (res://roads_system/RoadNetwork.gd:85)
SCRIPT ERROR: Invalid get index '[[Reference:1983], [Reference:2066]]' (on base: 'Dictionary').
          at: RoadNetwork.disconnect_intersections (res://roads_system/RoadNetwork.gd:85)
SCRIPT ERROR: Invalid get index '[[Reference:2066], [Reference:2177]]' (on base: 'Dictionary').
          at: RoadNetwork.disconnect_intersections (res://roads_system/RoadNetwork.gd:85)
SCRIPT ERROR: Invalid get index '[[Reference:2066], [Reference:2185]]' (on base: 'Dictionary').
          at: RoadNetwork.disconnect_intersections (res://roads_system/RoadNetwork.gd:85)
SCRIPT ERROR: Invalid get index '[[Reference:2066], [Reference:2185]]' (on base: 'Dictionary').
          at: RoadNetwork.disconnect_intersections (res://roads_system/RoadNetwork.gd:85)
[[Reference:2066]]
[[Reference:2068], [Reference:2070], [Reference:2179], [Reference:2187], [Reference:2189]]
SCRIPT ERROR: Invalid get index '[[Reference:1983], [Reference:2066]]' (on base: 'Dictionary').
          at: RoadNetwork.disconnect_intersections (res://roads_system/RoadNetwork.gd:85)
SCRIPT ERROR: Invalid get index '[[Reference:1983], [Reference:2066]]' (on base: 'Dictionary').
          at: RoadNetwork.disconnect_intersections (res://roads_system/RoadNetwork.gd:85)
SCRIPT ERROR: Invalid get index '[[Reference:2066], [Reference:2177]]' (on base: 'Dictionary').
          at: RoadNetwork.disconnect_intersections (res://roads_system/RoadNetwork.gd:85)
SCRIPT ERROR: Invalid get index '[[Reference:2066], [Reference:2185]]' (on base: 'Dictionary').
          at: RoadNetwork.disconnect_intersections (res://roads_system/RoadNetwork.gd:85)
SCRIPT ERROR: Invalid get index '[[Reference:2066], [Reference:2185]]' (on base: 'Dictionary').
          at: RoadNetwork.disconnect_intersections (res://roads_system/RoadNetwork.gd:85)

Those are bugs in your code that you'll need to fix, and that will likely fix the debugger issue.

That being said, I can now also reproduce the issue that when running the game in the editor and using those steps (place 4 nodes to make a closed loop, press T, click a node), the debugger is raised but aborts shortly after, without error message nor crash backtrace.

It does correctly point at the error line:
Screenshot_20210730_103825

My guess is that there might be an infinite recursion of some sort with the dictionary you used, so this project triggers a stack overflow. Not sure if that can be worked around at engine level (CC @Faless @RandomShaper).

I do get the same behavior in e.g. 3.3-stable so it's not a regression.

@sairam4123
Copy link
Author

I have actually fixed it, but my guess is, it's not a infinite recursion, I'll have a closer look again.

@akien-mga
Copy link
Member

I attached gdb to the running instance to see what happens, and indeed there's a segmentation fault (of the running instance, not the debugger).

It is indeed an infinite recursion:

Thread 1 "godot.x11.tools" received signal SIGSEGV, Segmentation fault.
0x000000000453d4ea in Variant::reference (this=<error reading variable: Cannot access memory at address 0x7ffe138e2d38>, p_variant=<error reading variable: Cannot access memory at address 0x7ffe138e2d30>)
    at core/variant.cpp:806
806     void Variant::reference(const Variant &p_variant) {
(gdb) bt
#0  0x000000000453d4ea in Variant::reference (this=<error reading variable: Cannot access memory at address 0x7ffe138e2d38>, p_variant=<error reading variable: Cannot access memory at address 0x7ffe138e2d30>)
    at core/variant.cpp:806
#1  0x0000000004544c06 in Variant::operator= (this=0x7ffe138e6cb0, p_variant=...) at core/variant.cpp:2413
#2  0x00000000045a64a1 in Variant::evaluate (p_op=@0x7ffe138e6ccc: Variant::OP_EQUAL, p_a=..., p_b=..., r_ret=..., r_valid=@0x7ffe138e6ccb: true) at core/variant_op.cpp:482
#3  0x0000000004548396 in Variant::hash_compare (this=0xee2beb0, p_variant=...) at core/variant.cpp:2950
#4  0x00000000018847d1 in VariantComparator::compare (p_lhs=..., p_rhs=...) at ./core/variant.h:463
#5  0x000000000445542e in HashMap<Variant, List<Pair<Variant const*, Variant>, DefaultAllocator>::Element*, VariantHasher, VariantComparator, (unsigned char)3, (unsigned char)8>::get_element (this=0xee00920, 
    p_key=...) at ./core/hash_map.h:182
#6  0x0000000004454d4f in HashMap<Variant, List<Pair<Variant const*, Variant>, DefaultAllocator>::Element*, VariantHasher, VariantComparator, (unsigned char)3, (unsigned char)8>::getptr (this=0xee00920, 
    p_key=...) at ./core/hash_map.h:303
#7  0x00000000044547c7 in OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator, (unsigned char)3, (unsigned char)8>::find (this=0xee00918, p_key=...) at ./core/ordered_hash_map.h:203
#8  0x00000000044538ea in Dictionary::getptr (this=0x7ffe138e71b8, p_key=...) at core/dictionary.cpp:93
#9  0x00000000046c1aab in encode_variant (p_variant=..., r_buffer=0x0, r_len=@0x7ffe138e7574: 8, p_full_objects=true) at core/io/marshalls.cpp:1131
#10 0x00000000046c1833 in encode_variant (p_variant=..., r_buffer=0x0, r_len=@0x7ffe138e790c: 160, p_full_objects=true) at core/io/marshalls.cpp:1079
#11 0x00000000046c1c1e in encode_variant (p_variant=..., r_buffer=0x0, r_len=@0x7ffe138e7cd4: 32, p_full_objects=true) at core/io/marshalls.cpp:1139
#12 0x00000000046c1833 in encode_variant (p_variant=..., r_buffer=0x0, r_len=@0x7ffe138e806c: 220, p_full_objects=true) at core/io/marshalls.cpp:1079
#13 0x00000000046c1c1e in encode_variant (p_variant=..., r_buffer=0x0, r_len=@0x7ffe138e8434: 24, p_full_objects=true) at core/io/marshalls.cpp:1139

<skipped tons of repeat frames>

#8839 0x00000000046c1c1e in encode_variant (p_variant=..., r_buffer=0x0, r_len=@0x7ffe140da614: 32, p_full_objects=true) at core/io/marshalls.cpp:1139
#8840 0x00000000046c1833 in encode_variant (p_variant=..., r_buffer=0x0, r_len=@0x7ffe140da9ac: 220, p_full_objects=true) at core/io/marshalls.cpp:1079
#8841 0x00000000046c1c1e in encode_variant (p_variant=..., r_buffer=0x0, r_len=@0x7ffe140dad74: 24, p_full_objects=true) at core/io/marshalls.cpp:1139
#8842 0x00000000046c1833 in encode_variant (p_variant=..., r_buffer=0x0, r_len=@0x7ffe140db01c: 160, p_full_objects=true) at core/io/marshalls.cpp:1079
#8843 0x0000000003fe8832 in ScriptDebuggerRemote::_put_variable (this=0x6c36f10, p_name=..., p_variable=...) at scene/debugger/script_debugger_remote.cpp:109
#8844 0x0000000003fe99d0 in ScriptDebuggerRemote::debug (this=0x6c36f10, p_script=0x7479e70, p_can_continue=false, p_is_error_breakpoint=true) at scene/debugger/script_debugger_remote.cpp:226
#8845 0x000000000188e338 in GDScriptLanguage::debug_break (this=0x7479e70, p_error=..., p_allow_continue=false) at modules/gdscript/gdscript_editor.cpp:223
#8846 0x00000000018b5c7b in GDScriptFunction::call (this=0x8649110, p_instance=0x8611e90, p_args=0x7ffe140dcb88, p_argcount=2, r_err=..., p_state=0x0) at modules/gdscript/gdscript_function.cpp:1533
#8847 0x0000000001857859 in GDScriptInstance::call (this=0x8611e90, p_method=..., p_args=0x7ffe140dcb88, p_argcount=2, r_error=...) at modules/gdscript/gdscript.cpp:1151
#8848 0x00000000044c5490 in Object::call (this=0x85ffd90, p_method=..., p_args=0x7ffe140dcb88, p_argcount=2, r_error=...) at core/object.cpp:899
#8849 0x0000000004558bcf in Variant::call_ptr (this=0x7ffe140dcda0, p_method=..., p_args=0x7ffe140dcb88, p_argcount=2, r_ret=0x0, r_error=...) at core/variant_call.cpp:1173
#8850 0x00000000018b25ad in GDScriptFunction::call (this=0x864a9b0, p_instance=0x8611e90, p_args=0xef3fd08, p_argcount=1, r_err=..., p_state=0x0) at modules/gdscript/gdscript_function.cpp:1034
#8851 0x0000000001857859 in GDScriptInstance::call (this=0x8611e90, p_method=..., p_args=0xef3fd08, p_argcount=1, r_error=...) at modules/gdscript/gdscript.cpp:1151
#8852 0x00000000044c5490 in Object::call (this=0x85ffd90, p_method=..., p_args=0xef3fd08, p_argcount=1, r_error=...) at core/object.cpp:899
#8853 0x0000000004558bcf in Variant::call_ptr (this=0xef3fcc0, p_method=..., p_args=0xef3fd08, p_argcount=1, r_ret=0x0, r_error=...) at core/variant_call.cpp:1173
#8854 0x00000000018b25ad in GDScriptFunction::call (this=0x8605720, p_instance=0x8646cb0, p_args=0x0, p_argcount=0, r_err=..., p_state=0xee36400) at modules/gdscript/gdscript_function.cpp:1034
#8855 0x00000000018b8be1 in GDScriptFunctionState::resume (this=0xee362f0, p_arg=...) at modules/gdscript/gdscript_function.cpp:1800
#8856 0x00000000018b849a in GDScriptFunctionState::_signal_callback (this=0xee362f0, p_args=0xee0c690, p_argcount=1, r_error=...) at modules/gdscript/gdscript_function.cpp:1748
#8857 0x00000000018c039d in MethodBindVarArg<GDScriptFunctionState>::call (this=0x8047cd0, p_object=0xee362f0, p_args=0xee0c690, p_arg_count=1, r_error=...) at ./core/method_bind.h:333
#8858 0x00000000044c55b4 in Object::call (this=0xee362f0, p_method=..., p_args=0xee0c690, p_argcount=1, r_error=...) at core/object.cpp:918
#8859 0x00000000044c7314 in Object::emit_signal (this=0x7f7b2e0, p_name=..., p_args=0x7ffe140df8f0, p_argcount=0) at core/object.cpp:1226
#8860 0x00000000044c79d5 in Object::emit_signal (this=0x7f7b2e0, p_name=..., p_arg1=..., p_arg2=..., p_arg3=..., p_arg4=..., p_arg5=...) at core/object.cpp:1281
#8861 0x00000000035cbdf4 in SceneTree::idle (this=0x7f7b2e0, p_time=0.0166666675) at scene/main/scene_tree.cpp:517
#8862 0x00000000017bf056 in Main::iteration () at main/main.cpp:2140
#8863 0x0000000001784a0d in OS_X11::run (this=0x7ffe140dff60) at platform/x11/os_x11.cpp:3638
#8864 0x000000000177282f in main (argc=9, argv=0x7ffe140e0868) at platform/x11/godot_x11.cpp:55

@akien-mga akien-mga changed the title Game crashes when debugging the project Game crashes when debugging the project (infite recursion after ScriptDebuggerRemote::_put_variable) Jul 30, 2021
@sairam4123 sairam4123 changed the title Game crashes when debugging the project (infite recursion after ScriptDebuggerRemote::_put_variable) Game crashes when debugging the project (infinite recursion after ScriptDebuggerRemote::_put_variable) Jul 30, 2021
@Faless
Copy link
Collaborator

Faless commented Jul 30, 2021

Seems to be related to cyclic references.
For a minimal reproduction project run this while debugging:

func _ready():
	var d1 = {}
	var a1 = []
	d1["a"] = a1
	a1.push_back(d1)
	print(d1)
	breakpoint

Note: in current master you need:

var d1 = {}
func _ready():
	var a1 = []
	d1["a"] = a1
	a1.push_back(d1)
	print(d1)
	breakpoint

Not sure why it doesn't crash on the local variable, but does with the member variable

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

Successfully merging a pull request may close this issue.

5 participants