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

Executing CompressedCubemap.get_layer_data function crashes Godot #87367

Closed
qarmin opened this issue Jan 19, 2024 · 2 comments · Fixed by #87694
Closed

Executing CompressedCubemap.get_layer_data function crashes Godot #87367

qarmin opened this issue Jan 19, 2024 · 2 comments · Fixed by #87694

Comments

@qarmin
Copy link
Contributor

qarmin commented Jan 19, 2024

Tested versions

4.3.dev.custom_build. 2ababdc

System information

Ubuntu 22.04 CI Lavapipe

Issue description

When executing (this code was automatically minimized, so it is possible, that an even more "minimal" project can be created)

extends Node
func _process(delta):
	var temp_variable413 = CompressedCubemap.new()
	temp_variable413.get_rid()
	temp_variable413.set(StringName("4104542839"), -95)
	temp_variable413.get_script()
	temp_variable413.get_layer_data(-87)
	temp_variable413.get_layer_data(21)

Godot crashes:

Godot Engine v4.3.dev.custom_build.2ababdcc0 - https://godotengine.org
ERROR: Condition "p_layer >= layer_count" is true. Returning: Vector<uint8_t>()
   at: texture_get_data (servers/rendering/rendering_device.cpp:1261)
ERROR: Condition "data.size() == 0" is true. Returning: Ref<Image>()
   at: texture_2d_layer_get (servers/rendering/renderer_rd/storage_rd/texture_storage.cpp:1321)
ERROR: FATAL: DEV_ASSERT failed  "mip_layouts[i].layer_pitch == mip_layouts[i].size / layer_count" is false.
   at: texture_get_data (servers/rendering/rendering_device.cpp:1279)
================================================================
handle_crash: Program crashed with signal 4
Engine version: Godot Engine v4.3.dev.custom_build (2ababdcc065e76decc12747a3c84e01f7bdc90dd)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] ./godot.linuxbsd.editor.dev.x86_64.san(+0x3ae44819) [0x563e19c47819] (/home/runner/work/Qarminer/Qarminer/godot/platform/linuxbsd/crash_handler_linuxbsd.cpp:61)
[2] /lib/x86_64-linux-gnu/libc.so.6(+0x42520) [0x7f2152442520] (??:0)
[3] RenderingDevice::texture_get_data(RID, unsigned int) (/home/runner/work/Qarminer/Qarminer/godot/servers/rendering/rendering_device.cpp:1279 (discriminator 4))
[4] RendererRD::TextureStorage::texture_2d_layer_get(RID, int) const (/home/runner/work/Qarminer/Qarminer/godot/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp:1321)
[5] RenderingServerDefault::texture_2d_layer_get(RID, int) const (/home/runner/work/Qarminer/Qarminer/godot/servers/rendering/rendering_server_default.h:198)
[6] CompressedTextureLayered::get_layer_data(int) const (/home/runner/work/Qarminer/Qarminer/godot/scene/resources/compressed_texture.cpp:811)
[7] void call_with_variant_args_retc_helper<__UnexistingClass, Ref<Image>, int, 0ul>(__UnexistingClass*, Ref<Image> (__UnexistingClass::*)(int) const, Variant const**, Variant&, Callable::CallError&, IndexSequence<0ul>) (/home/runner/work/Qarminer/Qarminer/godot/./core/variant/binder_common.h:806 (discriminator 4))
[8] void call_with_variant_args_retc_dv<__UnexistingClass, Ref<Image>, int>(__UnexistingClass*, Ref<Image> (__UnexistingClass::*)(int) const, Variant const**, int, Variant&, Callable::CallError&, Vector<Variant> const&) (/home/runner/work/Qarminer/Qarminer/godot/./core/variant/binder_common.h:538)
[9] MethodBindTRC<Ref<Image>, int>::call(Object*, Variant const**, int, Callable::CallError&) const (/home/runner/work/Qarminer/Qarminer/godot/./core/object/method_bind.h:583)
[10] Object::callp(StringName const&, Variant const**, int, Callable::CallError&) (/home/runner/work/Qarminer/Qarminer/godot/core/object/object.cpp:775)
[11] Variant::callp(StringName const&, Variant const**, int, Variant&, Callable::CallError&) (/home/runner/work/Qarminer/Qarminer/godot/core/variant/variant_call.cpp:1208)
[12] GDScriptFunction::call(GDScriptInstance*, Variant const**, int, Callable::CallError&, GDScriptFunction::CallState*) (/home/runner/work/Qarminer/Qarminer/godot/modules/gdscript/gdscript_vm.cpp:1735)
[13] GDScriptInstance::callp(StringName const&, Variant const**, int, Callable::CallError&) (/home/runner/work/Qarminer/Qarminer/godot/modules/gdscript/gdscript.cpp:1936)
[14] bool Node::_gdvirtual__process_call<false>(double) (/home/runner/work/Qarminer/Qarminer/godot/scene/main/node.h:318 (discriminator 1))
[15] Node::_notification(int) (/home/runner/work/Qarminer/Qarminer/godot/scene/main/node.cpp:58)
[16] Node::_notificationv(int, bool) (/home/runner/work/Qarminer/Qarminer/godot/./scene/main/node.h:49 (discriminator 14))
[17] Object::notification(int, bool) (/home/runner/work/Qarminer/Qarminer/godot/core/object/object.cpp:840)
[18] SceneTree::_process_group(SceneTree::ProcessGroup*, bool) (/home/runner/work/Qarminer/Qarminer/godot/scene/main/scene_tree.cpp:951)
[19] SceneTree::_process(bool) (/home/runner/work/Qarminer/Qarminer/godot/scene/main/scene_tree.cpp:1023 (discriminator 2))
[20] SceneTree::process(double) (/home/runner/work/Qarminer/Qarminer/godot/scene/main/scene_tree.cpp:510)
[21] Main::iteration() (/home/runner/work/Qarminer/Qarminer/godot/main/main.cpp:3790)
[22] OS_LinuxBSD::run() (/home/runner/work/Qarminer/Qarminer/godot/platform/linuxbsd/os_linuxbsd.cpp:933)
[23] ./godot.linuxbsd.editor.dev.x86_64.san(main+0x583) [0x563e19c4728c] (/home/runner/work/Qarminer/Qarminer/godot/platform/linuxbsd/godot_linuxbsd.cpp:76)
[24] /lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x7f2152429d90] (??:0)
[25] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80) [0x7f2152429e40] (??:0)
[26] ./godot.linuxbsd.editor.dev.x86_64.san(_start+0x25) [0x563e19c46c45] (??:?)
-- END OF BACKTRACE --
================================================================
Aborted (core dumped)

This example was found by Godot fuzzer - Qarminer, so it is quite unlikelly that this code could be used in real project, but still this should be handled gracefully.

Memory leaks or asan backtraces are visible when using Godot build with sanitizers support - https://github.com/qarmin/GodotBuilds/actions (linux -> linux-editor-sanitizers)

Steps to reproduce

Above

Minimal reproduction project (MRP)

Above

@qarmin qarmin changed the title Executing CompressedCubemap.FUNCTION function crashes Godot Executing CompressedCubemap.get_layer_data function crashes Godot Jan 19, 2024
@jsjtxietian
Copy link
Contributor

Did not reproduce in Godot v4.3.dev (e52b74436) - Windows 10.0.19045 - GLES3 (Compatibility) - NVIDIA GeForce RTX 3060 (NVIDIA; 31.0.15.3619) - 11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz (16 Threads)

@qarmin
Copy link
Contributor Author

qarmin commented Jan 26, 2024

I can reproduce crash with Forward+ but not with opengl3

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.

3 participants