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 deleting Sprite2D with region, undoing #84349

Closed
aXu-AP opened this issue Nov 2, 2023 · 2 comments · Fixed by #84361
Closed

Crash when deleting Sprite2D with region, undoing #84349

aXu-AP opened this issue Nov 2, 2023 · 2 comments · Fixed by #84361

Comments

@aXu-AP
Copy link
Contributor

aXu-AP commented Nov 2, 2023

Godot version

v4.2.beta4.official [93cdacb]

System information

Windows 10

Issue description

When I convert Sprite2D to mesh/polygon via sprite tools, undoing crashes the editor. It's not a big problem as it requires quite specific steps to trigger and converting a sprite with region doesn't seem to be fully supported anyway.
Error message:

Exception thrown at 0x00007FF7B0562753 in godot.windows.editor.x86_64.exe: 0xC0000005: Access violation reading location 0x0000000000000000.

Steps to reproduce

  • Edit Sprite2D's region with region editor (note: manually setting region doesn't trigger the crash)
  • Convert to MeshInstance2D or Polygon2D Delete the Sprite2D
  • Undo x 2
    crash

Minimal reproduction project

N/A, happens on a clean project.

@Calinou
Copy link
Member

Calinou commented Nov 2, 2023

I can confirm this on 4.2.beta 6afd320 (Linux). I can't reproduce this on 4.1.2-4.2.dev3, but I can on 4.2.dev4 and later.

I bisected the regression to 4b7d0c8. cc @YuriSizov

On 4.2.dev3, I get these errors when following the steps, but no crash:

ERROR: Index p_idx = -1 is out of bounds (edited_scene.size() = 1).
   at: get_scene_path (editor/editor_data.cpp:880)
ERROR: Index p_idx = -1 is out of bounds (edited_scene.size() = 1).
   at: check_and_update_scene (editor/editor_data.cpp:683)
ERROR: Index p_idx = -1 is out of bounds (edited_scene.size() = 1).
   at: set_edited_scene (editor/editor_data.cpp:745)
ERROR: UndoRedo history mismatch: expected 0, got 1.
   at: get_history_for_object (editor/editor_undo_redo_manager.cpp:108)

Backtrace:

handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.2.beta.custom_build (6afd320984cf14198368cc6c53752813a02169e3)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /lib64/libc.so.6(+0x3dbb0) [0x7fc6d69cdbb0] (??:0)
[2] godot() [0x1f0ceb1] (/home/hugo/Documents/Git/godotengine/godot/editor/plugins/texture_region_editor_plugin.cpp:954 (discriminator 2))
[3] godot() [0x1f0cf89] (/home/hugo/Documents/Git/godotengine/godot/editor/plugins/texture_region_editor_plugin.cpp:742)
[4] godot() [0x68b759] (/home/hugo/Documents/Git/godotengine/godot/./core/variant/variant.h:236)
[5] godot() [0x458ab2c] (/home/hugo/Documents/Git/godotengine/godot/core/object/object.cpp:774 (discriminator 1))
[6] godot() [0x42f23d1] (/home/hugo/Documents/Git/godotengine/godot/core/variant/callable.cpp:69 (discriminator 1))
[7] godot() [0x42f31eb] (/home/hugo/Documents/Git/godotengine/godot/core/variant/callable_bind.cpp:145)
[8] godot() [0x45c7c64] (/home/hugo/Documents/Git/godotengine/godot/core/object/undo_redo.cpp:342)
[9] godot() [0x45ca086] (/home/hugo/Documents/Git/godotengine/godot/core/object/undo_redo.cpp:407)
[10] godot() [0x18c8863] (/home/hugo/Documents/Git/godotengine/godot/editor/editor_undo_redo_manager.cpp:313)
[11] godot() [0x177fa3a] (/home/hugo/Documents/Git/godotengine/godot/editor/editor_node.cpp:2678 (discriminator 1))
[12] godot() [0x4596927] (/home/hugo/Documents/Git/godotengine/godot/core/object/object.cpp:1129)
[13] godot() [0x28726ba] (/home/hugo/Documents/Git/godotengine/godot/./core/variant/variant.h:301)
[14] godot() [0x2873612] (/home/hugo/Documents/Git/godotengine/godot/scene/gui/popup_menu.cpp:2307)
[15] godot() [0x28756f0] (/home/hugo/Documents/Git/godotengine/godot/scene/gui/popup_menu.cpp:2219)
[16] godot() [0x284eef0] (/home/hugo/Documents/Git/godotengine/godot/scene/gui/menu_bar.cpp:166 (discriminator 2))
[17] godot() [0x262a098] (/home/hugo/Documents/Git/godotengine/godot/scene/main/scene_tree.cpp:1225 (discriminator 1))
[18] godot() [0x265a5c6] (/home/hugo/Documents/Git/godotengine/godot/scene/main/viewport.cpp:3234)
[19] godot() [0x26730cb] (/home/hugo/Documents/Git/godotengine/godot/scene/main/viewport.cpp:3192)
[20] godot() [0x26b3d61] (/home/hugo/Documents/Git/godotengine/godot/./core/object/ref_counted.h:209)
[21] godot() [0x448e55] (/home/hugo/Documents/Git/godotengine/godot/./core/variant/variant.h:301)
[22] godot() [0x45a8ba] (/home/hugo/Documents/Git/godotengine/godot/./core/variant/variant.h:301)
[23] godot() [0x42935d0] (/usr/include/c++/13/x86_64-redhat-linux/bits/gthr-default.h:749)
[24] godot() [0x4295f51] (/home/hugo/Documents/Git/godotengine/godot/./core/object/ref_counted.h:209)
[25] godot() [0x460145] (/home/hugo/Documents/Git/godotengine/godot/./core/templates/local_vector.h:319)
[26] godot() [0x435a60] (/home/hugo/Documents/Git/godotengine/godot/platform/linuxbsd/os_linuxbsd.cpp:931)
[27] godot() [0x4265fb] (/home/hugo/Documents/Git/godotengine/godot/platform/linuxbsd/godot_linuxbsd.cpp:74)
[28] /lib64/libc.so.6(+0x27b8a) [0x7fc6d69b7b8a] (??:0)
[29] /lib64/libc.so.6(__libc_start_main+0x8b) [0x7fc6d69b7c4b] (??:0)
[30] godot() [0x4331a5] (??:?)
-- END OF BACKTRACE --

@Calinou Calinou added this to the 4.2 milestone Nov 2, 2023
@YuriSizov YuriSizov self-assigned this Nov 2, 2023
@YuriSizov
Copy link
Contributor

For the record, this has nothing to do with converting to mesh. It's only related to removing the original node (Sprite2D) and then undoing. Since undoing doesn't somehow restore the original node but rather recreates it, the region editor has no idea about it, its context is lost, the reference is empty. And so it crashes.

This was likely always a problem, just didn't manifest this way.

@aXu-AP aXu-AP changed the title Crash when converting Sprite2D with region to Mesh, undoing Crash when deleting Sprite2D with region, undoing Nov 2, 2023
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