godot icon indicating copy to clipboard operation
godot copied to clipboard

Using a implicitly defined constant as array length causes the application/editor to crash

Open RedNicStone opened this issue 2 years ago • 1 comments

Godot version

4.0 prerelease 2

System information

Fedora Linux 37, Nvidia 4090, Vulkan 1.3, nv 525.60.11

Issue description

When using a implicit constant as length in an array causes a crash to do failure to parse the shader syntax. This also crashes the editor when editing a shader. If the project is saved in that state this will cause the project to corrupt as it is impossible to open it without the editor crashing.

Steps to reproduce

Create a new Godot Project and create a new GD shader. Use the following example code or equivalent in the shader:

const int EXPLICIT = 1;
const int IMPLICIT = EXPLICIT + 1;
int[IMPLICIT];

Wait for the editor to realize what you just wrote and subsequently crash.

Minimal reproduction project

N/A

RedNicStone avatar Feb 27 '23 14:02 RedNicStone

Can't reproduce in 4.0 stable. No crash with the given code.

KoBeWi avatar Mar 10 '23 15:03 KoBeWi

Can't reproduce either in 4.0 RC 2, which I guess is what was referred to as "prerelease 2".

image

@RedNicStone Can you still reproduce it in 4.0 stable, and if so, can you give more detailed reproduction steps?

akien-mga avatar Mar 10 '23 21:03 akien-mga

Issue is present for me in both version 4.0 stable and RC 2. However I have found that the issue is inconsistent to reproduce, only happening every 2nd time. Sometimes the editor will crash immediately and other times it will only happen when the editor is restarted a few times. The shader also needs to be opened in the shader editor for the issue to occur.

Here is a crashlog I gathered when it did happen:

(base) [nic@ryzen9m Applications]$ ./Godot_v4.0-stable_linux.x86_64 
Godot Engine v4.0.stable.official.92bee43ad - https://godotengine.org
OpenGL API 3.3.0 NVIDIA 525.60.11 - Compatibility - Using Device: NVIDIA Corporation - NVIDIA GeForce RTX 3090
 
Editing project: /home/nic/GodotProjects/test_old
Godot Engine v4.0.stable.official.92bee43ad - https://godotengine.org
Vulkan API 1.3.224 - Forward+ - Using Vulkan Device #0: NVIDIA - NVIDIA GeForce RTX 4090
WARNING: Blend file import is enabled in the project settings, but no Blender path is configured in the editor settings. Blend files will not be imported.
     at: _editor_init (modules/gltf/register_types.cpp:70)
--res://test.gdshader--
    1 | shader_type spatial;
    2 | render_mode unshaded;
    3 | 
    4 | uniform sampler2D textureIn;
    5 | const int EXPLICIT = 1;
    6 | const int IMPLICIT = EXPLICIT + 1;
E   7-> int[IMPLICIT];
    8 | 
SHADER ERROR: Expected a function name after type.
          at: (null) (res://test.gdshader:7)
ERROR: Shader compilation failed.
   at: set_code (servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp:137)

================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.0.stable.official (92bee43adba8d2401ef40e2480e53087bcb1eaf1)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /lib64/libc.so.6(+0x3cb20) [0x7f4d43660b20] (??:0)
[2] /home/nic/Applications/Godot_v4.0-stable_linux.x86_64() [0x3b59be1] (??:0)
[3] /home/nic/Applications/Godot_v4.0-stable_linux.x86_64() [0x3b7c87b] (??:0)
[4] /home/nic/Applications/Godot_v4.0-stable_linux.x86_64() [0x3b96c3a] (??:0)
[5] /home/nic/Applications/Godot_v4.0-stable_linux.x86_64() [0x3ba0335] (??:0)
[6] /home/nic/Applications/Godot_v4.0-stable_linux.x86_64() [0x2518165] (??:0)
[7] /home/nic/Applications/Godot_v4.0-stable_linux.x86_64() [0x27cdb61] (??:0)
[8] /home/nic/Applications/Godot_v4.0-stable_linux.x86_64() [0x45d8c8a] (??:0)
[9] /home/nic/Applications/Godot_v4.0-stable_linux.x86_64() [0x2b9f5a1] (??:0)
[10] /home/nic/Applications/Godot_v4.0-stable_linux.x86_64() [0x4568594] (??:0)
[11] /home/nic/Applications/Godot_v4.0-stable_linux.x86_64() [0x2b9a3ee] (??:0)
[12] /home/nic/Applications/Godot_v4.0-stable_linux.x86_64() [0x2bd127e] (??:0)
[13] /home/nic/Applications/Godot_v4.0-stable_linux.x86_64() [0xec07db] (??:0)
[14] /home/nic/Applications/Godot_v4.0-stable_linux.x86_64() [0xe027f3] (??:0)
[15] /lib64/libc.so.6(+0x27510) [0x7f4d4364b510] (??:0)
[16] /lib64/libc.so.6(__libc_start_main+0x89) [0x7f4d4364b5c9] (??:0)
[17] /home/nic/Applications/Godot_v4.0-stable_linux.x86_64() [0xe2286e] (??:0)
-- END OF BACKTRACE --
================================================================

RedNicStone avatar Mar 11 '23 03:03 RedNicStone

Still reproducable. Following shader reliably crashes in 4.2 whenever I try to open it in editor:

shader_type spatial;

const uint TEST = 1u;
const uint TEST_IMPLICIT = TEST + 1u;

float crash_array[TEST_IMPLICIT];

void fragment() {
	ALBEDO = vec3(1., .0, .0);
}

Dump:

--Main Shader--
    1 | shader_type spatial;
    2 | 
    3 | const uint TEST = 1u;
    4 | const uint TEST_IMPLICIT = TEST + 1u;
    5 | 
E   6-> float crash_array[TEST_IMPLICIT];
    7 | 
    8 | void fragment() {
    9 |  ALBEDO = vec3(1., .0, .0);
   10 | }
   11 | 
SHADER ERROR: Expected a positive integer constant.
          at: (null) (:6)
ERROR: Shader compilation failed.
   at: set_code (servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp:145)

================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.2.stable.arch_linux
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /usr/lib/libc.so.6(+0x3e710) [0x7fcb9845c710] (??:0)
[2] /usr/bin/godot(+0x32dc06e) [0x55591f56006e] (??:?)
[3] /usr/bin/godot(+0x32f0342) [0x55591f574342] (??:?)
[4] /usr/bin/godot(+0x332dbd5) [0x55591f5b1bd5] (??:?)
[5] /usr/bin/godot(+0x3334773) [0x55591f5b8773] (??:?)
[6] /usr/bin/godot(+0x33007a8) [0x55591f5847a8] (??:?)
[7] /usr/bin/godot(+0x33c4c5c) [0x55591f648c5c] (??:?)
[8] /usr/bin/godot(+0x3420932) [0x55591f6a4932] (??:?)
[9] /usr/bin/godot(+0x2d3726a) [0x55591efbb26a] (??:?)
[10] /usr/bin/godot(+0x1a607be) [0x55591dce47be] (??:?)
[11] /usr/bin/godot(+0x3da562e) [0x55592002962e] (??:?)
[12] /usr/bin/godot(+0x1ab05cc) [0x55591dd345cc] (??:?)
[13] /usr/bin/godot(+0x1a6a7ea) [0x55591dcee7ea] (??:?)
[14] /usr/bin/godot(+0x1a323ec) [0x55591dcb63ec] (??:?)
[15] /usr/bin/godot(+0x126c084) [0x55591d4f0084] (??:?)
[16] /usr/bin/godot(+0x1280ea8) [0x55591d504ea8] (??:?)
[17] /usr/bin/godot(+0x14534fb) [0x55591d6d74fb] (??:?)
[18] /usr/bin/godot(+0x1267249) [0x55591d4eb249] (??:?)
[19] /usr/bin/godot(+0x14245bb) [0x55591d6a85bb] (??:?)
[20] /usr/bin/godot(+0x14249df) [0x55591d6a89df] (??:?)
[21] /usr/bin/godot(+0x3da562e) [0x55592002962e] (??:?)
[22] /usr/bin/godot(+0xb35057) [0x55591cdb9057] (??:?)
[23] /usr/bin/godot(+0x2572ac2) [0x55591e7f6ac2] (??:?)
[24] /usr/bin/godot(+0x219a2db) [0x55591e41e2db] (??:?)
[25] /usr/bin/godot(+0x21e7121) [0x55591e46b121] (??:?)
[26] /usr/bin/godot(+0x21e910d) [0x55591e46d10d] (??:?)
[27] /usr/bin/godot(+0x2202ff6) [0x55591e486ff6] (??:?)
[28] /usr/bin/godot(+0x426157b) [0x5559204e557b] (??:?)
[29] /usr/bin/godot(+0x5ff4e2) [0x55591c8834e2] (??:?)
[30] /usr/bin/godot(+0x3b374c1) [0x55591fdbb4c1] (??:?)
[31] /usr/bin/godot(+0x3b38e35) [0x55591fdbce35] (??:?)
[32] /usr/bin/godot(+0x603921) [0x55591c887921] (??:?)
[33] /usr/bin/godot(+0x5830bc) [0x55591c8070bc] (??:?)
[34] /usr/lib/libc.so.6(+0x27cd0) [0x7fcb98445cd0] (??:0)
[35] /usr/lib/libc.so.6(__libc_start_main+0x8a) [0x7fcb98445d8a] (??:0)
[36] /usr/bin/godot(+0x58fd95) [0x55591c813d95] (??:?)
-- END OF BACKTRACE --
================================================================

meelkor avatar Dec 17 '23 15:12 meelkor

Ok I can reproduce the crash in official build, but it does not happen in dev build 🤔

KoBeWi avatar Dec 17 '23 15:12 KoBeWi

Can reproduce on v4.2.1.stable.flathub [b09f793f5] on linux mint, and on v4.2.1.stable.official [b09f793f5] on windows 10, with the following code:

shader_type spatial;

const int XD = 5*5;
uniform float[XD] lol;

neropatti avatar Mar 17 '24 19:03 neropatti