godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.62k stars 21.28k forks source link

Editor Crashes When Duplicating and Dragging An Item in scene (2D) #34510

Closed warwicky closed 3 years ago

warwicky commented 4 years ago

3.1.2

Windows 10 64 Bit

While in the editor, in 2d monitor scene, engine crashes if you press ctrl+d and drag. I came across this problem while creating many coins on a level for a 2d platformer game. I tend to press ctrl+d and drag the coin quickly. It happens probably because of dragging an unready object while duplicating or so.

1- Press ctrl+d to duplicate an object(it is also a scene) and drag with mouse almost at the saöe time.

You may use GDQuest Tutorial (https://www.youtube.com/watch?v=6ziIyx60N6I) He also shares the source code in github.

capnm commented 4 years ago

569e9c1d51beca1ebbaf2a79dd7b53045de4fd39 DRAG_MOVE duplicated Sprite in Node2D crash bt:

Thread 1 "godot3" received signal SIGSEGV, Segmentation fault.
0x0000000004817fa1 in Dictionary::operator[](Variant const&) const () at core/dictionary.cpp:86
#0  0x0000000004817fa1 in Dictionary::operator[](Variant const&) const () at core/dictionary.cpp:86
#1  0x0000000003dd5eee in _edit_set_state () at scene/2d/node_2d.cpp:49
#2  0x0000000003e492a6 in _edit_set_state () at scene/2d/sprite.cpp:44
#3  0x000000000339bc28 in _restore_canvas_item_state () at editor/plugins/canvas_item_editor_plugin.cpp:921
#4  0x00000000033aaf63 in _gui_input_move () at editor/plugins/canvas_item_editor_plugin.cpp:1993
#5  0x00000000033af09d in _gui_input_viewport () at editor/plugins/canvas_item_editor_plugin.cpp:2434
#6  0x00000000033f68d1 in call () at ./core/method_bind.gen.inc:867
#7  0x00000000048ac032 in call () at core/object.cpp:921
#8  0x00000000048ae503 in emit_signal () at core/object.cpp:1219
#9  0x00000000048ac7e3 in Object::emit_signal(StringName const&, Variant const&, Variant const&, Variant const&, Variant const&, Variant const&) () at core/object.cpp:1276
#10 0x00000000037fd37d in _gui_call_input () at scene/main/viewport.cpp:1626
#11 0x00000000037ff424 in _gui_input_event () at scene/main/viewport.cpp:2230
#12 0x00000000037fc47d in input () at scene/main/viewport.cpp:2790
#13 0x00000000037fc288 in _vp_input () at scene/main/viewport.cpp:1411
#14 0x0000000003820311 in call () at ./core/method_bind.gen.inc:867
#15 0x00000000048ac032 in call () at core/object.cpp:921
#16 0x00000000048abe4b in Object::call(StringName const&, Variant const&, Variant const&, Variant const&, Variant const&, Variant const&) ()
    at core/object.cpp:847
#17 0x00000000037c75d1 in call_group_flags () at scene/main/scene_tree.cpp:275
#18 0x00000000037c90c4 in input_event () at scene/main/scene_tree.cpp:430
#19 0x000000000204e424 in _parse_input_event_impl () at main/input_default.cpp:442
#20 0x000000000204fa69 in flush_accumulated_events () at main/input_default.cpp:678
#21 0x000000000203bd10 in process_xevents () at platform/x11/os_x11.cpp:2694
#22 0x0000000002040281 in OS_X11::run() () at platform/x11/os_x11.cpp:3258
#23 0x000000000203217b in main () at platform/x11/godot_x11.cpp:56
KoBeWi commented 4 years ago

Duplicate of #27523

The fix could be cherry-picked for 3.1.3 though.

capnm commented 4 years ago

Duplicate of #27523 The fix could be cherry-picked for 3.1.3 though.

Wasn't that merged to master? I can reproduce this one on the current 3.2beta master branch. EDIT: Can reproduce it also by duplicating the node while dragging as described in #27523.

KoBeWi commented 4 years ago

Weird, I can't reproduce it in the official beta.

capnm commented 4 years ago

test.zip

Checked also beta4 for you (the backtrace shoud be the same, in the official builds it was unfortunately made useless). E.g. after a second ctll+d while dragging the godot sprite:

'/intranet/godot/ok/v32b4/Godot_v3.2-beta4_x11.64' -e
Godot Engine v3.2.beta4.official - https://godotengine.org
OpenGL ES 2.0 Renderer: AMD Radeon HD 7700 Series (VERDE, DRM 3.35.0, 5.4.2-050402-generic, LLVM 10.0.0)

handle_crash: Program crashed with signal 11
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[1] /lib/x86_64-linux-gnu/libc.so.6(+0x3ef20) [0x7ff6cf11df20] (??:0)
[2] /intranet/godot/ok/v32b4/Godot_v3.2-beta4_x11.64() [0xdcc734] (??:?)
[3] /intranet/godot/ok/v32b4/Godot_v3.2-beta4_x11.64() [0x14ec50b] (??:?)
…
-- END OF BACKTRACE --
Aborted
KoBeWi commented 4 years ago

Am I doing something wrong? 7jFL9rjfnR (same results with move tool)

In the 3.2 beta, if the node you are dragging loses selection, the dragging is cancelled.

capnm commented 4 years ago

Try harder, faster, longer holding, double ctrl+d, release, etc… ;-)

Peek 2019-12-21 19-14

With

tool
extends Sprite

func _ready():
    print(name, " ready")

func _init():
    print(" init")

It prints

 init
icon ready
[New Thread 0x7fffc735c700 (LWP 12527)]
[Thread 0x7fffc735c700 (LWP 12527) exited]
 init
icon2 ready
 init
icon3 ready
 init
icon4 ready

Thread 1 "Godot_v3.2-beta" received signal SIGSEGV, Segmentation fault.
0x0000000000dcc734 in Dictionary::operator[](Variant const&) const ()

And at this point are in the viewport 3 of the 4 icons.

capnm commented 4 years ago

In the 3.2 beta, if the node you are dragging loses selection, the dragging is cancelled.

It is also in the 3D viewport broken by design (tm) – multiple selection, holding down the Ctrl key collides here with the snap. But look at how duplicating a single selection user-friendly works while dragging. I think cancelling dragging was a wrong way trying to fix the issue.

KoBeWi commented 4 years ago

Eh, I created over a hundred of duplicates and still no luck. I will just give it "Needs Testing" label 🙄

Also

I think cancelling dragging was a wrong way trying to fix the issue.

I just thought that the situation that caused this shouldn't even happen in the first place, but maybe adding a safeguard is a better idea. If someone can reproduce and wants to fix, just follow the backtrace. The crash is caused by editor trying to set state of CanvasItem to non-existing value, so the operation probably should be cancelled when the state is invalid.

capnm commented 4 years ago

Eh, I created over a hundred of duplicates and still no luck. I will just give it "Needs Testing" label roll_eyes

Looks like a thread signal etc timing problem. Linux may be more likely to crash.

The crash is caused by editor trying to set state of CanvasItem to non-existing value …

The question should be why this happens at all or what exactly does the current 'duplicate' implementation do in this case. I think that the dragging shouldn't be cancelled, but continued (as in 3D) with the duplicated node.

KoBeWi commented 4 years ago

Can anyone still reproduce this bug in Godot 3.2.3 or any later release?

capnm commented 4 years ago

Can anyone still reproduce this bug in Godot 3.2.3 or any later release?

Yes.

Godot Engine v3.2.3.stable.official - https://godotengine.org
OpenGL ES 3.0 Renderer: AMD Radeon HD 7700 Series (VERDE, DRM 3.35.0, 5.4.0-53-generic, LLVM 11.0.0)

handle_crash: Program crashed with signal 11
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[1] /lib/x86_64-linux-gnu/libc.so.6(+0x46210) [0x7f6af101a210] (??:0)
[2] godot-323() [0xe06114] (??:?)
[3] godot-323() [0x157205b] (??:?)
[4] godot-323() [0x1572328] (<artificial>:?)
[5] godot-323() [0x8f50b0] (??:?)
[6] godot-323() [0x1ddfac1] (<artificial>:?)
[7] godot-323() [0x1de4fed] (<artificial>:?)
[8] godot-323() [0x279ff26] (??:?)
[9] godot-323() [0xc579b3] (??:?)
[10] godot-323() [0xc612d6] (??:?)
[11] godot-323() [0xc622d0] (??:?)
[12] godot-323() [0x1904358] (<artificial>:?)
[13] godot-323() [0x1927d51] (<artificial>:?)
[14] godot-323() [0x192a396] (??:?)
[15] godot-323() [0x192a4ee] (<artificial>:?)
[16] godot-323() [0x279ff26] (??:?)
[17] godot-323() [0xc579b3] (??:?)
[18] godot-323() [0xbf2c45] (??:?)
[19] godot-323() [0x18e45d3] (??:?)
[20] godot-323() [0x18e78cc] (??:?)
[21] godot-323() [0x293b6b3] (??:?)
[22] godot-323() [0x293891d] (<artificial>:?)
[23] godot-323() [0x2a7f1cb] (<artificial>:?)
[24] godot-323() [0x85ce3c] (??:?)
[25] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0x7f6af0ffb0b3] (??:0)
[26] godot-323() [0x86b68e] (??:?)
-- END OF BACKTRACE --

and my Godot fork with symbols (3.2.3 + cherry picks from tip):

handle_crash: Program crashed with signal 11
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[1] /lib/x86_64-linux-gnu/libc.so.6(+0x46210) [0x7fc6dd60b210] (??:0)
[2] Dictionary::operator[](Variant const&) const (core/dictionary.cpp:86)
[3] Node2D::_edit_set_state(Dictionary const&) (scene/2d/node_2d.cpp:51)
[4] Sprite::_edit_set_state(Dictionary const&) (scene/2d/sprite.cpp:46)
[5] CanvasItemEditor::_restore_canvas_item_state(List<CanvasItem*, DefaultAllocator>, bool) (editor/plugins/canvas_item_editor_plugin.cpp:926)
[6] CanvasItemEditor::_gui_input_move(Ref<InputEvent> const&) (editor/plugins/canvas_item_editor_plugin.cpp:2029)
[7] CanvasItemEditor::_gui_input_viewport(Ref<InputEvent> const&) (editor/plugins/canvas_item_editor_plugin.cpp:2469)
[8] MethodBind1<CanvasItemEditor, Ref<InputEvent> const&>::call(Object*, Variant const**, int, Variant::CallError&) (./core/method_bind.gen.inc:867)
[9] Object::call(StringName const&, Variant const**, int, Variant::CallError&) (core/object.cpp:922)
[10] Object::emit_signal(StringName const&, Variant const**, int) (core/object.cpp:1249)
[11] Object::emit_signal(StringName const&, Variant const&, Variant const&, Variant const&, Variant const&, Variant const&) (core/object.cpp:1306)
[12] Viewport::_gui_call_input(Control*, Ref<InputEvent> const&) (scene/main/viewport.cpp:1661)
[13] Viewport::_gui_input_event(Ref<InputEvent>) (scene/main/viewport.cpp:2265)
[14] Viewport::input(Ref<InputEvent> const&) (scene/main/viewport.cpp:2825)
[15] Viewport::_vp_input(Ref<InputEvent> const&) (scene/main/viewport.cpp:1446)
[16] MethodBind1<Viewport, Ref<InputEvent> const&>::call(Object*, Variant const**, int, Variant::CallError&) (./core/method_bind.gen.inc:867)
[17] Object::call(StringName const&, Variant const**, int, Variant::CallError&) (core/object.cpp:922)
[18] Object::call(StringName const&, Variant const&, Variant const&, Variant const&, Variant const&, Variant const&) (core/object.cpp:849)
[19] SceneTree::call_group_flags(unsigned int, StringName const&, StringName const&, Variant const&, Variant const&, Variant const&, Variant const&, Variant const&) (scene/main/scene_tree.cpp:275)
[20] SceneTree::input_event(Ref<InputEvent> const&) (scene/main/scene_tree.cpp:431)
[21] InputDefault::_parse_input_event_impl(Ref<InputEvent> const&, bool) (main/input_default.cpp:442)
[22] InputDefault::parse_input_event(Ref<InputEvent> const&) (main/input_default.cpp:260)
[23] InputDefault::flush_accumulated_events() (main/input_default.cpp:678)
[24] OS_X11::process_xevents() (platform/x11/os_x11.cpp:2794)
[25] OS_X11::run() (platform/x11/os_x11.cpp:3378)
[26] godot-cid(main+0x181) [0x2cd9611] (platform/x11/godot_x11.cpp:56)
[27] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0x7fc6dd5ec0b3] (??:0)
[28] godot-cid(_start+0x2e) [0x2cd93ce] (??:?)
-- END OF BACKTRACE --