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

Crash, when using set_script and emit_signal on AnimatedSprite #46120

Closed
qarmin opened this issue Feb 17, 2021 · 5 comments · Fixed by #46125
Closed

Crash, when using set_script and emit_signal on AnimatedSprite #46120

qarmin opened this issue Feb 17, 2021 · 5 comments · Fixed by #46125

Comments

@qarmin
Copy link
Contributor

qarmin commented Feb 17, 2021

Godot version:
Godot 3.2.4 rc 2

OS/device including version:
Ubuntu 20.04

Issue description:
When executing

extends Node2D

var q_AnimatedSprite : AnimatedSprite = AnimatedSprite.new()

func _ready() -> void:
	add_child(q_AnimatedSprite)

func _process(_delta : float) -> void:

	if randi() % 2 == 0:
		print("Executing AnimatedSprite::set_script")

		var p_object_0 = Reference.new()
		q_AnimatedSprite.set_script(p_object_0)

	if randi() % 2 == 0:
		print("Executing AnimatedSprite::emit_signal")

		q_AnimatedSprite.emit_signal("")

Godot crashes and shows this backtrace

core/object.cpp:1490:46: runtime error: member call on null pointer of type 'struct Script'
core/object.cpp:1490:46: runtime error: member access within null pointer of type 'struct Script'
[1] /lib/x86_64-linux-gnu/libc.so.6(+0x46210) [0x7f1b6f4b5210] (??:0)
[2] Object::emit_signal(StringName const&, Variant const**, int) (/home/rafal/Pulpit/godot3.2/core/object.cpp:1192 (discriminator 12))
[3] Object::_emit_signal(Variant const**, int, Variant::CallError&) (/home/rafal/Pulpit/godot3.2/core/object.cpp:1179)
[4] MethodBindVarArg<Object>::call(Object*, Variant const**, int, Variant::CallError&) (/home/rafal/Pulpit/godot3.2/./core/method_bind.h:345 (discriminator 4))
[5] Object::call(StringName const&, Variant const**, int, Variant::CallError&) (/home/rafal/Pulpit/godot3.2/core/object.cpp:919 (discriminator 1))
[6] Variant::call_ptr(StringName const&, Variant const**, int, Variant*, Variant::CallError&) (/home/rafal/Pulpit/godot3.2/core/variant_call.cpp:1129 (discriminator 1))
[7] GDScriptFunction::call(GDScriptInstance*, Variant const**, int, Variant::CallError&, GDScriptFunction::CallState*) (/home/rafal/Pulpit/godot3.2/modules/gdscript/gdscript_function.cpp:1089)
[8] GDScriptInstance::call_multilevel(StringName const&, Variant const**, int) (/home/rafal/Pulpit/godot3.2/modules/gdscript/gdscript.cpp:1254)
[9] Node::_notification(int) (/home/rafal/Pulpit/godot3.2/scene/main/node.cpp:58)
[10] Node::_notificationv(int, bool) (/home/rafal/Pulpit/godot3.2/./scene/main/node.h:46 (discriminator 14))
[11] CanvasItem::_notificationv(int, bool) (/home/rafal/Pulpit/godot3.2/./scene/2d/canvas_item.h:166 (discriminator 3))
[12] Node2D::_notificationv(int, bool) (/home/rafal/Pulpit/godot3.2/./scene/2d/node_2d.h:38 (discriminator 3))
[13] Object::notification(int, bool) (/home/rafal/Pulpit/godot3.2/core/object.cpp:931)
[14] SceneTree::_notify_group_pause(StringName const&, int) (/home/rafal/Pulpit/godot3.2/scene/main/scene_tree.cpp:988)
[15] SceneTree::idle(float) (/home/rafal/Pulpit/godot3.2/scene/main/scene_tree.cpp:528 (discriminator 3))
[16] Main::iteration() (/home/rafal/Pulpit/godot3.2/main/main.cpp:2113)
[17] OS_X11::run() (/home/rafal/Pulpit/godot3.2/platform/x11/os_x11.cpp:3634)
[18] /usr/bin/godot(main+0x125) [0x16e0bfb] (/home/rafal/Pulpit/godot3.2/platform/x11/godot_x11.cpp:57)
[19] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0x7f1b6f4960b3] (??:0)
[20] /usr/bin/godot(_start+0x2e) [0x16e0a1e] (??:?)
@angad-k
Copy link
Contributor

angad-k commented Feb 17, 2021

will make a PR for this in some time

@lyuma
Copy link
Contributor

lyuma commented Jul 4, 2022

Still crashes on latest 4.0 alpha c41e4b1:

Updated some class names in the repro script. Create an empty scene, make a plain Node2D and attach this script:

extends Node2D

var q_AnimatedSprite : AnimatedSprite2D = AnimatedSprite2D.new()

func _ready() -> void:
	add_child(q_AnimatedSprite)

func _process(_delta : float) -> void:

	if randi() % 2 == 0:
		print("Executing AnimatedSprite::set_script")

		var p_object_0 = RefCounted.new()
		q_AnimatedSprite.set_script(p_object_0)

	if randi() % 2 == 0:
		print("Executing AnimatedSprite::emit_signal")

		q_AnimatedSprite.emit_signal("")

@lyuma
Copy link
Contributor

lyuma commented Jul 4, 2022

crash log:

Executing AnimatedSprite::set_script
Executing AnimatedSprite::emit_signal

================================================================
CrashHandlerException: Program crashed
Engine version: Godot Engine v4.0.alpha.custom_build (20981a8bca663a2dbf4d125a25d9ac0a0a078e20)
Dumping the backtrace. Please include this when reporting the bug on: https://github.com/godotengine/godot/issues
[0] Object::emit_signalp (S:\repo\godot-fire\core\object\object.cpp:959)
[1] Object::emit_signalp (S:\repo\godot-fire\core\object\object.cpp:959)
[2] Object::_emit_signal (S:\repo\godot-fire\core\object\object.cpp:946)
[3] MethodBindVarArgTR<Object,enum Error>::call (S:\repo\godot-fire\core\object\method_bind.h:245)
[4] GDScriptFunction::call (S:\repo\godot-fire\modules\gdscript\gdscript_vm.cpp:1635)
[5] GDScriptInstance::callp (S:\repo\godot-fire\modules\gdscript\gdscript.cpp:1567)
[6] Node::_notification (S:\repo\godot-fire\scene\main\node.cpp:56)
[7] CanvasItem::_notificationv (S:\repo\godot-fire\scene\main\canvas_item.h:45)
[8] Object::notification (S:\repo\godot-fire\core\object\object.cpp:743)
[9] SceneTree::_notify_group_pause (S:\repo\godot-fire\scene\main\scene_tree.cpp:849)
[10] SceneTree::process (S:\repo\godot-fire\scene\main\scene_tree.cpp:455)
[11] Main::iteration (S:\repo\godot-fire\main\main.cpp:2817)
[12] OS_Windows::run (S:\repo\godot-fire\platform\windows\os_windows.cpp:777)
[13] widechar_main (S:\repo\godot-fire\platform\windows\godot_windows.cpp:175)
[14] _main (S:\repo\godot-fire\platform\windows\godot_windows.cpp:199)
[15] main (S:\repo\godot-fire\platform\windows\godot_windows.cpp:211)
[16] __scrt_common_main_seh (D:\agent\_work\9\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)
[17] BaseThreadInitThunk
-- END OF BACKTRACE --
================================================================

@akien-mga
Copy link
Member

akien-mga commented Feb 12, 2023

Still reproducible as of 4.0 RC 1.

Simplified MRP:

extends Node

func _ready() -> void:
        var node = Node.new()
        node.set_script(RefCounted.new())
        node.emit_signal("")

@YuriSizov YuriSizov modified the milestones: 4.0, 4.1 Feb 27, 2023
@akien-mga
Copy link
Member

akien-mga commented Jun 23, 2023

Still reproducible as of 4.1 beta 3.

#46125 should fix it in 4.2.

@akien-mga akien-mga modified the milestones: 4.1, 4.2 Jun 23, 2023
YuriSizov pushed a commit to YuriSizov/godot that referenced this issue Jul 10, 2023
akien-mga pushed a commit to akien-mga/godot that referenced this issue Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

5 participants