godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.48k stars 21.08k forks source link

[4.x regression] `while true: await frame` causes Stack Overflow #61130

Closed nathanfranke closed 2 years ago

nathanfranke commented 2 years ago

Godot version

v4.0.alpha.custom_build [4ee530e6a] Not reproducible on 3.4.4.stable

System information

Arch btw on 5.15.40-1-lts

Issue description

Stack Overflow (Stack Size: 1024)

0 - res://scene.gd:5 - at function: _ready
1 - res://scene.gd:5 - at function: _ready
2 - res://scene.gd:5 - at function: _ready
...

Steps to reproduce

In Godot 3.4.4:

func _ready() -> void:
    while true:
        yield(get_tree(), "idle_frame")
        print(Engine.get_frames_drawn()) # 30000, 30001, ... (no crash)

In Godot 4.x:

func _ready() -> void:
    while true:
        await get_tree().process_frame
        print(Engine.get_frames_drawn()) # 1021, 1022, (crash)

Minimal reproduction project

4.x: test2.zip

kyleguarco commented 2 years ago

A git bisect blames commit 102c312497ace1e81bb54b6c3ed3665d16ee1fef for the issue.

Interestingly enough, this bug only occurs when running from inside the editor. Running the project without the editor (using the editor binary with the --path argument) doesn't trigger the stack overflow (up to 1024, at least).

Output of git bisect log ``` git bisect start # bad: [5631b59e218f4883442382c097eed10ed76b3c8d] Merge pull request #61140 from Saenoe/fix-openxr-is_extension_supported git bisect bad 5631b59e218f4883442382c097eed10ed76b3c8d # good: [419e713a29f20bd3351a54d1e6c4c5af7ef4b253] Bump version to 3.4.4-stable git bisect good 419e713a29f20bd3351a54d1e6c4c5af7ef4b253 # good: [4e7d75ccd350b98bccea517c034b367f52cf127e] Bump version to 3.2-stable \o/ git bisect good 4e7d75ccd350b98bccea517c034b367f52cf127e # good: [bfcb1d2d418e7a28c1cb081913c0221b5ea0ec04] Merge pull request #49109 from Chaosus/fix_console_errors git bisect good bfcb1d2d418e7a28c1cb081913c0221b5ea0ec04 # good: [13769aebe9d435b9041f4ec8dc6f4b277a87b444] Merge pull request #54867 from Chaosus/shader_fix_light_albedo git bisect good 13769aebe9d435b9041f4ec8dc6f4b277a87b444 # good: [275f26cb5700f4877aba65779129d97c4a5965b5] Merge pull request #57968 from reduz/variant-ref-assignment-fix git bisect good 275f26cb5700f4877aba65779129d97c4a5965b5 # good: [324215c485dfeb63eab320038e9a9ca523d08ea7] Merge pull request #59525 from fire-forge/fix-group-names git bisect good 324215c485dfeb63eab320038e9a9ca523d08ea7 # good: [b3f4a81a9e1b3fd82940b89ff0b4ecf5ec31507b] Merge pull request #60385 from timothyqiu/openxr-set-array git bisect good b3f4a81a9e1b3fd82940b89ff0b4ecf5ec31507b # good: [9424dc04679268df1751dcf459140ac68a7e1453] Merge pull request #60543 from fire-forge/connection-icons git bisect good 9424dc04679268df1751dcf459140ac68a7e1453 # good: [9a368e9d4bf4f5698ac566d76c833645587de5d4] Merge pull request #60995 from BastiaanOlij/fix_copy_fb_checks git bisect good 9a368e9d4bf4f5698ac566d76c833645587de5d4 # bad: [dc8c906b640e1fce2bd8832d56902be49c77d87d] Merge pull request #58624 from dzil123/fix_update_gridmap_cursor git bisect bad dc8c906b640e1fce2bd8832d56902be49c77d87d # good: [f95b7412c74518a1f34912ba7d129cf247e7c2c1] Merge pull request #61057 from smix8/navigation_obstacle_transform_error_4.x git bisect good f95b7412c74518a1f34912ba7d129cf247e7c2c1 # good: [b154f445d59f5a6b332311890569fda689fe480b] Merge pull request #60507 from bruvzg/textmesh git bisect good b154f445d59f5a6b332311890569fda689fe480b # bad: [d6edc6d18ad69897ed847aeaf890d9290d2edbbe] Merge pull request #60126 from Calinou/image-improve-error-messages git bisect bad d6edc6d18ad69897ed847aeaf890d9290d2edbbe # bad: [0497b67bec0f545727e2e3c0a8b03d52be916b81] Merge pull request #60130 from fire-forge/theme-node-names git bisect bad 0497b67bec0f545727e2e3c0a8b03d52be916b81 # bad: [c41f62c3df85fd71539ae09bd97964e5e367d897] Merge pull request #61003 from vnen/gdscript-await-stack-fix git bisect bad c41f62c3df85fd71539ae09bd97964e5e367d897 # bad: [102c312497ace1e81bb54b6c3ed3665d16ee1fef] GDScript: Fix stack manipulation for `await` git bisect bad 102c312497ace1e81bb54b6c3ed3665d16ee1fef # first bad commit: [102c312497ace1e81bb54b6c3ed3665d16ee1fef] GDScript: Fix stack manipulation for `await` ```

Edit Mentioning the pull request that introduced the bug: #61003

vnen commented 2 years ago

I just want to say I'm looking for a fix for this without bringing back the issue that I fixed in the PR. It's a bit trickier than I expected.