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

MeshDataTool crash when changing vertex data. #49027

Closed
Gyrth opened this issue May 24, 2021 · 2 comments · Fixed by #54511
Closed

MeshDataTool crash when changing vertex data. #49027

Gyrth opened this issue May 24, 2021 · 2 comments · Fixed by #54511

Comments

@Gyrth
Copy link

Gyrth commented May 24, 2021

Godot version:
Godot_v3.3.1-stable_x11.64

OS/device including version:
Manjaro Linux x86_64
Intel i5-6600K (4) @ 3.900GHz
NVIDIA GeForce GTX 1060 6GB 460.80

Issue description:
When using DataMeshTool to change vertex bones, vertex weights and possibly other attributes it crashes when using commit_to_surface. I've set these values to empty PoolArrays in the reproduction project, but from my testing it also crashes when using valid data.

Steps to reproduce:

  • Run test project.
  • Crash.

Backtrace

ERROR: get: FATAL: Index p_index = 1 is out of bounds (size() = 1).
   At: ./core/cowdata.h:156.
handle_crash: Program crashed with signal 4
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[1] /usr/lib/libc.so.6(+0x3cf80) [0x7f15c0e1df80] (??:0)
[2] /home/gyrth/Documents/Godot_v3.3.1-stable_x11.64() [0x15de6ed] (??:0)
[3] /home/gyrth/Documents/Godot_v3.3.1-stable_x11.64() [0x15c899f] (??:0)
[4] /home/gyrth/Documents/Godot_v3.3.1-stable_x11.64() [0xe3a2b6] (??:0)
[5] /home/gyrth/Documents/Godot_v3.3.1-stable_x11.64() [0xd72289] (??:0)
[6] /home/gyrth/Documents/Godot_v3.3.1-stable_x11.64() [0x2ff2c44] (??:?)
[7] /home/gyrth/Documents/Godot_v3.3.1-stable_x11.64() [0x302cab5] (??:?)
[8] /home/gyrth/Documents/Godot_v3.3.1-stable_x11.64() [0x1ceae15] (??:0)
[9] /home/gyrth/Documents/Godot_v3.3.1-stable_x11.64() [0x19ef8c8] (??:0)
[10] /home/gyrth/Documents/Godot_v3.3.1-stable_x11.64() [0xdfdbb4] (??:0)
[11] /home/gyrth/Documents/Godot_v3.3.1-stable_x11.64() [0x1cae92a] (??:0)
[12] /home/gyrth/Documents/Godot_v3.3.1-stable_x11.64() [0x1cae880] (??:0)
[13] /home/gyrth/Documents/Godot_v3.3.1-stable_x11.64() [0x1cae880] (??:0)
[14] /home/gyrth/Documents/Godot_v3.3.1-stable_x11.64() [0x1ce8ea7] (??:0)
[15] /home/gyrth/Documents/Godot_v3.3.1-stable_x11.64() [0x1ce922f] (??:0)
[16] /home/gyrth/Documents/Godot_v3.3.1-stable_x11.64() [0x98e396] (??:0)
[17] /usr/lib/libc.so.6(__libc_start_main+0xd5) [0x7f15c0e08b25] (??:0)
[18] /home/gyrth/Documents/Godot_v3.3.1-stable_x11.64() [0x99cb9e] (??:0)
-- END OF BACKTRACE --

Minimal reproduction project:
BugReport.zip

@akien-mga
Copy link
Member

Confirmed in 3.x and master. Backtrace for latest master (65eff1c):

Thread 1 "godot-git" received signal SIGILL, Illegal instruction.
0x00000000022afc29 in CowData<float>::get (this=0xb3379b0, p_index=0) at ./core/templates/cowdata.h:157
157                     CRASH_BAD_INDEX(p_index, size());
(gdb) bt
#0  0x00000000022afc29 in CowData<float>::get (this=0xb3379b0, p_index=0) at ./core/templates/cowdata.h:157
#1  0x000000000229b46a in Vector<float>::operator[] (this=0xb3379a8, p_index=0) at ./core/templates/vector.h:89
#2  0x0000000004cd03f1 in MeshDataTool::commit_to_surface (this=0xb1711e0, p_mesh=...) at scene/resources/mesh_data_tool.cpp:280
#3  0x0000000004cdcbf5 in call_with_variant_args_ret_helper<__UnexistingClass, Error, Ref<ArrayMesh> const&, 0ul> (p_instance=0xb1711e0, p_method=
    (Error (__UnexistingClass::*)(__UnexistingClass * const, const Ref<ArrayMesh> &)) 0x4ccfede <MeshDataTool::commit_to_surface(Ref<ArrayMesh> const&)>, p_args=0x7fffffff8ee8, r_ret=..., r_error=...)
    at ./core/variant/binder_common.h:635
#4  0x0000000004cdc023 in call_with_variant_args_ret_dv<__UnexistingClass, Error, Ref<ArrayMesh> const&> (p_instance=0xb1711e0, p_method=
    (Error (__UnexistingClass::*)(__UnexistingClass * const, const Ref<ArrayMesh> &)) 0x4ccfede <MeshDataTool::commit_to_surface(Ref<ArrayMesh> const&)>, p_args=0x7fffffff9310, p_argcount=1, r_ret=..., 
    r_error=..., default_values=...) at ./core/variant/binder_common.h:440
#5  0x0000000004cdb3f8 in MethodBindTR<Error, Ref<ArrayMesh> const&>::call (this=0xabd61b0, p_object=0xb1711e0, p_args=0x7fffffff9310, p_arg_count=1, r_error=...) at ./core/object/method_bind.h:452
#6  0x0000000005b92d9a in Object::call (this=0xb1711e0, p_method=..., p_args=0x7fffffff9310, p_argcount=1, r_error=...) at core/object/object.cpp:784
#7  0x0000000005969008 in Variant::call (this=0x7fffffff91a8, p_method=..., p_args=0x7fffffff9310, p_argcount=1, r_ret=..., r_error=...) at core/variant/variant_call.cpp:978
#8  0x000000000308b0d3 in GDScriptFunction::call (this=0xb1ff210, p_instance=0xb174b50, p_args=0x7fffffffca90, p_argcount=0, r_err=..., p_state=0x0) at modules/gdscript/gdscript_vm.cpp:1471
#9  0x0000000002f9febb in GDScriptInstance::call (this=0xb174b50, p_method=..., p_args=0x7fffffffca90, p_argcount=0, r_error=...) at modules/gdscript/gdscript.cpp:1556
#10 0x0000000005baa7c4 in ScriptInstance::call (this=0xb174b50, p_method=..., p_arg1=..., p_arg2=..., p_arg3=..., p_arg4=..., p_arg5=...) at core/object/script_language.cpp:322
#11 0x000000000445f789 in Node::_notification (this=0xb1b6250, p_notification=13) at scene/main/node.cpp:147
#12 0x0000000002286e6c in Node::_notificationv (this=0xb1b6250, p_notification=13, p_reversed=false) at ./scene/main/node.h:45
#13 0x000000000228749b in Node3D::_notificationv (this=0xb1b6250, p_notification=13, p_reversed=false) at ./scene/3d/node_3d.h:52
#14 0x00000000034bb909 in VisualInstance3D::_notificationv (this=0xb1b6250, p_notification=13, p_reversed=false) at ./scene/3d/visual_instance_3d.h:40
#15 0x00000000034bc0a1 in GeometryInstance3D::_notificationv (this=0xb1b6250, p_notification=13, p_reversed=false) at ./scene/3d/visual_instance_3d.h:83
#16 0x00000000048a1443 in MeshInstance3D::_notificationv (this=0xb1b6250, p_notification=13, p_reversed=false) at scene/3d/mesh_instance_3d.h:40
#17 0x0000000005b92eb7 in Object::notification (this=0xb1b6250, p_notification=13, p_reversed=false) at core/object/object.cpp:793
#18 0x000000000445fcc5 in Node::_propagate_ready (this=0xb1b6250) at scene/main/node.cpp:188
--Type <RET> for more, q to quit, c to continue without paging--
#19 0x000000000445fc2f in Node::_propagate_ready (this=0xa42fb00) at scene/main/node.cpp:180
#20 0x000000000445fc2f in Node::_propagate_ready (this=0xb07dc60) at scene/main/node.cpp:180
#21 0x000000000446bfc2 in Node::_set_tree (this=0xb07dc60, p_tree=0xad54970) at scene/main/node.cpp:2522
#22 0x000000000448eb2b in SceneTree::initialize (this=0xad54970) at scene/main/scene_tree.cpp:394
#23 0x00000000020ae726 in OS_LinuxBSD::run (this=0x7fffffffd270) at platform/linuxbsd/os_linuxbsd.cpp:266
#24 0x00000000020ab6fa in main (argc=1, argv=0x7fffffffd788) at platform/linuxbsd/godot_linuxbsd.cpp:58

@akien-mga akien-mga added this to the 4.0 milestone May 24, 2021
@YuriSizov
Copy link
Contributor

YuriSizov commented Nov 2, 2021

For the record, it crashes because you are expected to have exactly 4 bones and weights on each vertex, or nothing at all. I'll submit a fix for the crash shortly, but for this to work you would need to pad your arrays to the required size (or avoid setting them if they are empty).

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