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

Editor crashes when defining two arrays who is lengths are defined of two constants where one is dependent on the other. #93387

Closed
ViggoSkj opened this issue Jun 20, 2024 · 1 comment · Fixed by #93469

Comments

@ViggoSkj
Copy link

Tested versions

  • Reproducible in Godot_v4.2.1 - mono win64
  • Reproducible in Godot 4.0-stable - standard win64

System information

Godot v4.2.1.stable.mono - Windows 10.0.22631 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1660 SUPER (NVIDIA; 31.0.15.5134) - AMD Ryzen 5 5600G with Radeon Graphics (12 Threads)

Issue description

When creating a global constant integer A in a shader, then creating another one named B defined upon A and lastly
defining an array with length B, the editor crashes. The time it takes to crash varies from instantaneously to a few seconds.
`
const int A = 1;
const int B = A + 1;

int[B] array;
`

Steps to reproduce

  1. Create a blank project
  2. Create a new shader resource
  3. Paste the given code into the shader

`
shader_type spatial;

const int A = 1;
const int B = A + 1;

int[B] array;
`

Minimal reproduction project (MRP)

N/A

@matheusmdx
Copy link
Contributor

matheusmdx commented Jun 22, 2024

I did some tests trying to reproduce this crash and the result:

  • For some reason i wasn't able to reproduce the crash with binaries compiled using MSVC, i only get the errors: :6 - Expected a positive integer constant. and Shader compilation failed.
  • Using official builds i can reproduce the crash (beta 2 too), but no debug symbols == no useful backtrace
  • Using MinGW i was able to replicate the crash, but the backtrace was useless even using debug symbols, also tried using VS Code but no useful backtrace as well
  • The only way i was able to get something was using MinGW binaries + gdb and finally i get some useful backtrace
Thread 1 received signal SIGSEGV, Segmentation fault.
0x00007ff7ef96f617 in CowData<ShaderLanguage::ConstantNode::Value>::size (this=0x49278bd0)
    at ./core/templates/cowdata.h:183
183                             return *size;
(gdb) bt
#0  0x00007ff7ef96f617 in CowData<ShaderLanguage::ConstantNode::Value>::size (this=0x49278bd0)
    at ./core/templates/cowdata.h:183
#1  0x00007ff7ef9218ec in Vector<ShaderLanguage::ConstantNode::Value>::size (this=0x49278bc8)
    at ./core/templates/vector.h:94
#2  0x00007ff7ec91457a in ShaderLanguage::_find_identifier (this=0x24c84d88, p_block=0x0, p_allow_reassign=false,
    p_function_info=..., p_identifier=..., r_data_type=0xbfb398, r_type=0x0, r_is_const=0xbfb397, r_array_size=0x0,
    r_struct_name=0x0, r_constant_value=0xbfb39c) at servers\rendering\shader_language.cpp:1448
#3  0x00007ff7ec91f13b in ShaderLanguage::_parse_array_size (this=0x24c84d88, p_block=0x0, p_function_info=...,
    p_forbid_unknown_size=true, r_size_expression=0x0, r_array_size=0xbfb6bc, r_unknown_size=0xbfb6bb)
    at servers\rendering\shader_language.cpp:4792
#4  0x00007ff7ec936d5b in ShaderLanguage::_parse_shader (this=0x24c84d88, p_functions=..., p_render_modes=...,
    p_shader_types=...) at servers\rendering\shader_language.cpp:9195
#5  0x00007ff7ec93b581 in ShaderLanguage::compile (this=0x24c84d88, p_code=..., p_info=...)
    at servers\rendering\shader_language.cpp:10047
#6  0x00007ff7ec90da79 in ShaderCompiler::compile (this=0x24c84d88, p_mode=RenderingServer::SHADER_SPATIAL,
    p_code=..., p_actions=0xbfda20, p_path=..., r_gen_code=...) at servers\rendering\shader_compiler.cpp:1465
#7  0x00007ff7ec9d281a in RendererSceneRenderImplementation::SceneShaderForwardClustered::ShaderData::set_code (
    this=0x5e55f090, p_code=...)
    at servers\rendering\renderer_rd\forward_clustered\scene_shader_forward_clustered.cpp:145
#8  0x00007ff7eca10304 in RendererRD::MaterialStorage::shader_set_code (this=0xcf39b00, p_shader=..., p_code=...)
    at servers\rendering\renderer_rd\storage_rd\material_storage.cpp:1916
#9  0x00007ff7ee05acc5 in RenderingServerDefault::shader_set_code (this=0xcdbba20, p1=..., p2=...)
    at servers/rendering/rendering_server_default.h:230
#10 0x00007ff7ec5e9c56 in Shader::set_code (this=0x5d82fdd0, p_code=...) at scene\resources\shader.cpp:116
#11 0x00007ff7eba78884 in TextShaderEditor::apply_shaders (this=0x5c6c1100)
    at editor\plugins\text_shader_editor.cpp:990
#12 0x00007ff7ed7c93d7 in call_with_variant_args_helper<TextShaderEditor>(TextShaderEditor*, void (TextShaderEditor::*)(), Variant const**, Callable::CallError&, IndexSequence<>) (p_instance=0x5c6c1100,
    p_method=(void (TextShaderEditor::*)(TextShaderEditor * const)) 0x7ff7eba7879a <TextShaderEditor::apply_shaders()>, p_args=0x0, r_error=...) at ./core/variant/binder_common.h:304
#13 0x00007ff7ed613f14 in call_with_variant_args<TextShaderEditor> (p_instance=0x5c6c1100,
    p_method=(void (TextShaderEditor::*)(TextShaderEditor * const)) 0x7ff7eba7879a <TextShaderEditor::apply_shaders()>, p_args=0x0, p_argcount=0, r_error=...) at ./core/variant/binder_common.h:418
#14 0x00007ff7ef60aba1 in CallableCustomMethodPointer<TextShaderEditor>::call (this=0x41faa350, p_arguments=0x0,
    p_argcount=0, r_return_value=..., r_call_error=...) at ./core/object/callable_method_pointer.h:103
#15 0x00007ff7ece166ad in Callable::callp (this=0xbfe730, p_arguments=0x0, p_argcount=0, r_return_value=...,
    r_call_error=...) at core\variant\callable.cpp:57
#16 0x00007ff7ed0331ae in Object::emit_signalp (this=0x5d740340, p_name=..., p_args=0x0, p_argcount=0)
    at core\object\object.cpp:1187
#17 0x00007ff7ebf39191 in Node::emit_signalp (this=0x5d740340, p_name=..., p_args=0x0, p_argcount=0)
    at scene\main\node.cpp:3890
#18 0x00007ff7ee481612 in Object::emit_signal<>(StringName const&) (this=0x5d740340, p_name=...)
    at ./core/object/object.h:936
#19 0x00007ff7eba750ae in ShaderTextEditor::_validate_script (this=0x5d740340)
    at editor\plugins\text_shader_editor.cpp:446
#20 0x00007ff7ebcd9806 in CodeTextEditor::_text_changed_idle_timeout (this=0x5d740340) at editor\code_editor.cpp:1482
#21 0x00007ff7ed7be617 in call_with_variant_args_helper<CodeTextEditor>(CodeTextEditor*, void (CodeTextEditor::*)(), Variant const**, Callable::CallError&, IndexSequence<>) (p_instance=0x5d740340,
    p_method=(void (CodeTextEditor::*)(CodeTextEditor * const)) 0x7ff7ebcd97de <CodeTextEditor::_text_changed_idle_timeo--Type <RET> for more, q to quit, c to continue without paging--<ret>
ut()>, p_args=0x0, r_error=...) at ./core/variant/binder_common.h:304
#22 0x00007ff7ed60a834 in call_with_variant_args<CodeTextEditor> (p_instance=0x5d740340,
    p_method=(void (CodeTextEditor::*)(CodeTextEditor * const)) 0x7ff7ebcd97de <CodeTextEditor::_text_changed_idle_timeout()>, p_args=0x0, p_argcount=0, r_error=...) at ./core/variant/binder_common.h:418
#23 0x00007ff7ef5aa3e1 in CallableCustomMethodPointer<CodeTextEditor>::call (this=0x42011cd0, p_arguments=0x0,
    p_argcount=0, r_return_value=..., r_call_error=...) at ./core/object/callable_method_pointer.h:103
#24 0x00007ff7ece166ad in Callable::callp (this=0xbff310, p_arguments=0x0, p_argcount=0, r_return_value=...,
    r_call_error=...) at core\variant\callable.cpp:57
#25 0x00007ff7ed0331ae in Object::emit_signalp (this=0x5cc067d0, p_name=..., p_args=0x0, p_argcount=0)
    at core\object\object.cpp:1187
#26 0x00007ff7ebf39191 in Node::emit_signalp (this=0x5cc067d0, p_name=..., p_args=0x0, p_argcount=0)
    at scene\main\node.cpp:3890
#27 0x00007ff7ee481612 in Object::emit_signal<>(StringName const&) (this=0x5cc067d0, p_name=...)
    at ./core/object/object.h:936
#28 0x00007ff7ebf4b049 in Timer::_notification (this=0x5cc067d0, p_what=25) at scene\main\timer.cpp:60
#29 0x00007ff7ee46ae73 in Timer::_notificationv (this=0x5cc067d0, p_notification=25, p_reversed=false)
    at scene/main/timer.h:37
#30 0x00007ff7ed031363 in Object::notification (this=0x5cc067d0, p_notification=25, p_reversed=false)
    at core\object\object.cpp:870
#31 0x00007ff7ebf3e6f0 in SceneTree::_process_group (this=0x29c9dd40, p_group=0x29c9df80, p_physics=false)
    at scene\main\scene_tree.cpp:959
#32 0x00007ff7ebf3ec10 in SceneTree::_process (this=0x29c9dd40, p_physics=false) at scene\main\scene_tree.cpp:1039
#33 0x00007ff7ebf3cd3a in SceneTree::process (this=0x29c9dd40, p_time=0.0069444444444444449)
    at scene\main\scene_tree.cpp:526
#34 0x00007ff7eaa77bf7 in Main::iteration () at main\main.cpp:4099
#35 0x00007ff7eaa2914f in OS_Windows::run (this=0xbffad0) at platform\windows\os_windows.cpp:1686
#36 0x00007ff7eaa21971 in widechar_main (argc=5, argv=0xe06220) at platform\windows\godot_windows.cpp:180
#37 0x00007ff7eaa21a89 in _main () at platform\windows\godot_windows.cpp:206
#38 0x00007ff7eaa21abe in main (argc=5, argv=0xd21ce0) at platform\windows\godot_windows.cpp:225

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