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

Setting StatusIndicator icon can crash if icon texture's image is null #92809

Closed
aaronp64 opened this issue Jun 5, 2024 · 0 comments · Fixed by #92826
Closed

Setting StatusIndicator icon can crash if icon texture's image is null #92809

aaronp64 opened this issue Jun 5, 2024 · 0 comments · Fixed by #92826
Assignees
Milestone

Comments

@aaronp64
Copy link
Contributor

aaronp64 commented Jun 5, 2024

Tested versions

v4.3.beta.custom_build [96a386f]

System information

Windows 10

Issue description

Setting StatusIndicator.icon to a Texture2D where:
- Texture2D is not null
- Texture2D::get_image() returns null
- Texture2D::get_width() and Texture2D::get_height() return > 0

can cause a crash in either DisplayServerWindows::create_status_indicator or DisplayServerWindows::status_indicator_set_icon. It looks like the DisplayServerMacOS functions would do the same, but I can't test those.

Stack traces:

CrashHandlerException: Program crashed
Engine version: Godot Engine v4.3.beta.custom_build (96a386f3c424af96d950ee5098b4b0e4907c9508)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[0] DisplayServerWindows::create_status_indicator (C:\dev\godot\platform\windows\display_server_windows.cpp:3176)
[1] DisplayServerWindows::create_status_indicator (C:\dev\godot\platform\windows\display_server_windows.cpp:3176)
[2] StatusIndicator::_notification (C:\dev\godot\scene\main\status_indicator.cpp:47)
[3] StatusIndicator::_notificationv (C:\dev\godot\scene\main\status_indicator.h:38)
[4] Object::notification (C:\dev\godot\core\object\object.cpp:906)
[5] Node::_propagate_enter_tree (C:\dev\godot\scene\main\node.cpp:294)
[6] Node::_set_tree (C:\dev\godot\scene\main\node.cpp:3159)
[7] Node::_add_child_nocheck (C:\dev\godot\scene\main\node.cpp:1550)
[8] Node::add_child (C:\dev\godot\scene\main\node.cpp:1578)
[9] call_with_variant_args_dv<Node,Node *,bool,enum Node::InternalMode> (C:\dev\godot\core\variant\binder_common.h:451)
[10] MethodBindT<Node,Node *,bool,enum Node::InternalMode>::call (C:\dev\godot\core\object\method_bind.h:348)
[11] GDScriptFunction::call (C:\dev\godot\modules\gdscript\gdscript_vm.cpp:1863)
[12] GDScriptInstance::callp (C:\dev\godot\modules\gdscript\gdscript.cpp:2050)
[13] Object::callp (C:\dev\godot\core\object\object.cpp:819)
[14] Variant::callp (C:\dev\godot\core\variant\variant_call.cpp:1211)
[15] GDScriptFunction::call (C:\dev\godot\modules\gdscript\gdscript_vm.cpp:1768)
[16] GDScriptInstance::callp (C:\dev\godot\modules\gdscript\gdscript.cpp:2050)
[17] Node::_notification (C:\dev\godot\scene\main\node.cpp:211)
[18] CanvasItem::_notificationv (C:\dev\godot\scene\main\canvas_item.h:45)
[19] Control::_notificationv (C:\dev\godot\scene\gui\control.h:48)
[20] Object::notification (C:\dev\godot\core\object\object.cpp:906)
[21] Node::_propagate_ready (C:\dev\godot\scene\main\node.cpp:267)
[22] Node::_propagate_ready (C:\dev\godot\scene\main\node.cpp:256)
[23] Node::_set_tree (C:\dev\godot\scene\main\node.cpp:3163)
[24] OS_Windows::run (C:\dev\godot\platform\windows\os_windows.cpp:1682)
[25] widechar_main (C:\dev\godot\platform\windows\godot_windows.cpp:181)
[26] _main (C:\dev\godot\platform\windows\godot_windows.cpp:208)
[27] main (C:\dev\godot\platform\windows\godot_windows.cpp:220)
[28] __scrt_common_main_seh (D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)
[29] <couldn't map PC to fn name>
-- END OF BACKTRACE --
CrashHandlerException: Program crashed
Engine version: Godot Engine v4.3.beta.custom_build (96a386f3c424af96d950ee5098b4b0e4907c9508)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[0] DisplayServerWindows::status_indicator_set_icon (C:\dev\godot\platform\windows\display_server_windows.cpp:3246)
[1] DisplayServerWindows::status_indicator_set_icon (C:\dev\godot\platform\windows\display_server_windows.cpp:3246)
[2] call_with_variant_args_dv<StatusIndicator,Ref<Texture2D> const &> (C:\dev\godot\core\variant\binder_common.h:451)
[3] MethodBindT<StatusIndicator,Ref<Texture2D> const &>::call (C:\dev\godot\core\object\method_bind.h:348)
[4] ClassDB::set_property (C:\dev\godot\core\object\class_db.cpp:1489)
[5] Object::set (C:\dev\godot\core\object\object.cpp:257)
[6] Variant::set_named (C:\dev\godot\core\variant\variant_setget.cpp:251)
[7] GDScriptFunction::call (C:\dev\godot\modules\gdscript\gdscript_vm.cpp:1110)
[8] GDScriptInstance::callp (C:\dev\godot\modules\gdscript\gdscript.cpp:2050)
[9] Object::callp (C:\dev\godot\core\object\object.cpp:819)
[10] Variant::callp (C:\dev\godot\core\variant\variant_call.cpp:1211)
[11] GDScriptFunction::call (C:\dev\godot\modules\gdscript\gdscript_vm.cpp:1768)
[12] GDScriptInstance::callp (C:\dev\godot\modules\gdscript\gdscript.cpp:2050)
[13] Node::_notification (C:\dev\godot\scene\main\node.cpp:211)
[14] CanvasItem::_notificationv (C:\dev\godot\scene\main\canvas_item.h:45)
[15] Control::_notificationv (C:\dev\godot\scene\gui\control.h:48)
[16] Object::notification (C:\dev\godot\core\object\object.cpp:906)
[17] Node::_propagate_ready (C:\dev\godot\scene\main\node.cpp:267)
[18] Node::_propagate_ready (C:\dev\godot\scene\main\node.cpp:256)
[19] Node::_set_tree (C:\dev\godot\scene\main\node.cpp:3163)
[20] OS_Windows::run (C:\dev\godot\platform\windows\os_windows.cpp:1682)
[21] widechar_main (C:\dev\godot\platform\windows\godot_windows.cpp:181)
[22] _main (C:\dev\godot\platform\windows\godot_windows.cpp:208)
[23] main (C:\dev\godot\platform\windows\godot_windows.cpp:220)
[24] __scrt_common_main_seh (D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)
[25] <couldn't map PC to fn name>
-- END OF BACKTRACE --

Steps to reproduce

In a new project, create a main scene with the attached script below. Setting icon to load("res://icon.svg") should work as expected, setting to CanvasTexture.new() should crash. I also included null - this case doesn't crash, but creates a status indicator with an empty icon - should we get a warning/error in this case?

extends Control

func _ready() -> void:
	#test_create_status_indicator(load("res://icon.svg"))
	#test_create_status_indicator(null)
	test_create_status_indicator(CanvasTexture.new())
	#test_set_icon(load("res://icon.svg"))
	#test_set_icon(null)
	#test_set_icon(CanvasTexture.new())

func test_set_icon(texture : Texture2D):
	var status_indicator := StatusIndicator.new()
	add_child(status_indicator)
	status_indicator.icon = texture

func test_create_status_indicator(texture : Texture2D):
	var status_indicator := StatusIndicator.new()
	status_indicator.icon = texture
	add_child(status_indicator)
	

Minimal reproduction project (MRP)

N/A, steps above for reproducing in a new project

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.

4 participants