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

GDScript stack underflow while yielding to signals (regression from #28884) #30269

Closed
Xrayez opened this issue Jul 2, 2019 · 10 comments · Fixed by #30663
Closed

GDScript stack underflow while yielding to signals (regression from #28884) #30269

Xrayez opened this issue Jul 2, 2019 · 10 comments · Fixed by #30663

Comments

@Xrayez
Copy link
Contributor

Xrayez commented Jul 2, 2019

Godot version:
3.2-dev 4d99408

Regression from #28884.

OS/device including version:
Windows 10

Issue description:
While running GUT tests encountered this:

Debugger Break, Reason: 'Stack Underflow (Engine Bug)'
ERROR: GDScriptLanguage::debug_get_stack_level_function: Index p_level=0 out of size (_debug_call_stack_pos=0)
   At: modules\gdscript\gdscript_editor.cpp:271
ERROR: GDScriptLanguage::debug_get_stack_level_line: Index p_level=0 out of size (_debug_call_stack_pos=0)
   At: modules\gdscript\gdscript_editor.cpp:260
ERROR: GDScriptLanguage::debug_get_stack_level_source: Index p_level=0 out of size (_debug_call_stack_pos=0)
   At: modules\gdscript\gdscript_editor.cpp:280
*Frame 0 - :-1 in function ''
Enter "help" for assistance.
debug>

Steps to reproduce:

git clone https://github.com/bitwes/Gut/

Now open the project, run main scene (default). Godot Test Window shall appear.
Select res://test/unit/test_gut_yielding.gd from the popup menu [...] button:

2019-07-04

Press Run. Stalls on the first yield test (test_can_yield_using_built_in_timer).

@StraToN
Copy link
Member

StraToN commented Jul 3, 2019

I am affected by "stack underflow" as well. I have no idea of the cause though.
edit: indeed my problem is related to yield() calls. Commenting them removed the error.
It is worth noting that my project was running fine from Launcher/Terminal command. Is that the case for you as well @Xrayez ?

For the record, here is the snippet in my project. It is similar to the "3D in 2D" demo (https://github.com/godotengine/godot-demo-projects/blob/master/viewport/3d_in_2d/3D_in_2D.gd#L22)

func _ready():
	# Assign the sprite's texture to the viewport texture
	$Viewport.set_clear_mode(Viewport.CLEAR_MODE_ONLY_NEXT_FRAME)
	
	# Let two frames pass to make sure the screen was captured
	#yield(get_tree(), "idle_frame")
	#yield(get_tree(), "idle_frame")
	$viewport_sprite.texture = $Viewport.get_texture()

@vnen
Copy link
Member

vnen commented Jul 3, 2019

I have a ton of yields in my project and it doesn't happen, hard to tell what's causing it.

Also, you don't need to use while, the completed signal is only emitted when the function didn't yield anymore.

@Xrayez
Copy link
Contributor Author

Xrayez commented Jul 3, 2019

@vnen figured the steps to reproduce, see updated original report. 🙂

@StraToN I'm mostly running the tests via command line as part of CI-like tests in my project via pre-commit hook. And yeah I do something very similar to what you described in your snippet.

@owstetra
Copy link

owstetra commented Jul 3, 2019

@vnen i also have the same problem , i also have a lot of yields but for some reason some of them not causing the problem but others do
commenting the yield line will stop causing it

@volzhs
Copy link
Contributor

volzhs commented Jul 3, 2019

I'm facing it too.

@magpie514
Copy link

magpie514 commented Jul 6, 2019

I also seem affected by it. It happens when a yield should happen, indeed. (on current master at the time of writing, d897131)
screenshot1
Weirdest thing is that continuing execution using the debugger continue button makes everything follow up without issues. I guess I'll just roll back until this is fixed.

@zaksnet
Copy link
Contributor

zaksnet commented Jul 9, 2019

Screenshot_5
Same for me.

bojidar-bg added a commit to bojidar-bg/godot that referenced this issue Jul 17, 2019
Also, refactor GDScriptFunctionState::_signal_callback, removing some excessive repetition.
Fixes godotengine#30269.
@muchitto
Copy link

I got the same "Stack Underflow (Engine Bug)" error message just now. I have multiple levels of yield(state, "completed") -kinda code in my game (wait for the yield to complete in the calling function and in that calling function and in that etc up the stack frame...). I just made some changes to my code and added one more "yield completed" signal thing, the engine spouted that error message to me. If I remove that one yield, everything works...

Are too many nested yield complete things much for the engine or what is happening? :)

I'm using freshly compiled godot from the master branch, that I just pulled like hour or two ago...

@bojidar-bg
Copy link
Contributor

@muchitto Please open a new issue report, with a sample project that reproduces it :).

@muchitto
Copy link

Ahh, okay sorry! :)

myhalibobo pushed a commit to myhalibobo/godot that referenced this issue Sep 3, 2019
Also, refactor GDScriptFunctionState::_signal_callback, removing some excessive repetition.
Fixes godotengine#30269.
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.

10 participants