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

Executing MeshInstance.new()._mesh_changed() crashes Godot #45980

Closed
qarmin opened this issue Feb 13, 2021 · 4 comments · Fixed by #46166
Closed

Executing MeshInstance.new()._mesh_changed() crashes Godot #45980

qarmin opened this issue Feb 13, 2021 · 4 comments · Fixed by #46166

Comments

@qarmin
Copy link
Contributor

qarmin commented Feb 13, 2021

Godot version:
Godot 3.2.4 rc 2

Issue description:

MeshInstance.new()._mesh_changed()

cause crash with backtrace

scene/3d/mesh_instance.cpp:704:42: runtime error: member call on null pointer of type 'struct Mesh'
scene/3d/mesh_instance.cpp:704:42: runtime error: member access within null pointer of type 'struct Mesh'
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] godots() [0x16f757a] (/mnt/Miecz/godot3.2/platform/x11/crash_handler_x11.cpp:54)
[2] /lib/x86_64-linux-gnu/libc.so.6(+0x46210) [0x7f4619ec3210] (??:0)
[3] MeshInstance::_mesh_changed() (/mnt/Miecz/godot3.2/scene/3d/mesh_instance.cpp:704)
[4] MethodBind0::call(Object*, Variant const**, int, Variant::CallError&) (/mnt/Miecz/godot3.2/./core/method_bind.gen.inc:61 (discriminator 4))
[5] Object::call(StringName const&, Variant const**, int, Variant::CallError&) (/mnt/Miecz/godot3.2/core/object.cpp:919 (discriminator 1))
[6] Variant::call_ptr(StringName const&, Variant const**, int, Variant*, Variant::CallError&) (/mnt/Miecz/godot3.2/core/variant_call.cpp:1129 (discriminator 1))
[7] GDScriptFunction::call(GDScriptInstance*, Variant const**, int, Variant::CallError&, GDScriptFunction::CallState*) (/mnt/Miecz/godot3.2/modules/gdscript/gdscript_function.cpp:1089)
[8] GDScriptInstance::call(StringName const&, Variant const**, int, Variant::CallError&) (/mnt/Miecz/godot3.2/modules/gdscript/gdscript.cpp:1238)
[9] Object::call(StringName const&, Variant const**, int, Variant::CallError&) (/mnt/Miecz/godot3.2/core/object.cpp:898 (discriminator 1))
[10] Variant::call_ptr(StringName const&, Variant const**, int, Variant*, Variant::CallError&) (/mnt/Miecz/godot3.2/core/variant_call.cpp:1129 (discriminator 1))
[11] GDScriptFunction::call(GDScriptInstance*, Variant const**, int, Variant::CallError&, GDScriptFunction::CallState*) (/mnt/Miecz/godot3.2/modules/gdscript/gdscript_function.cpp:1089)
[12] GDScriptInstance::_ml_call_reversed(GDScript*, StringName const&, Variant const**, int) (/mnt/Miecz/godot3.2/modules/gdscript/gdscript.cpp:1269)
[13] GDScriptInstance::call_multilevel_reversed(StringName const&, Variant const**, int) (/mnt/Miecz/godot3.2/modules/gdscript/gdscript.cpp:1278)
[14] Node::_notification(int) (/mnt/Miecz/godot3.2/scene/main/node.cpp:152)
[15] Node::_notificationv(int, bool) (/mnt/Miecz/godot3.2/./scene/main/node.h:46 (discriminator 14))
[16] CanvasItem::_notificationv(int, bool) (/mnt/Miecz/godot3.2/./scene/2d/canvas_item.h:166 (discriminator 3))
[17] Node2D::_notificationv(int, bool) (/mnt/Miecz/godot3.2/./scene/2d/node_2d.h:38 (discriminator 3))
[18] Object::notification(int, bool) (/mnt/Miecz/godot3.2/core/object.cpp:931)
[19] Node::_propagate_ready() (/mnt/Miecz/godot3.2/scene/main/node.cpp:197)
[20] Node::_propagate_ready() (/mnt/Miecz/godot3.2/scene/main/node.cpp:186 (discriminator 2))
[21] Node::_set_tree(SceneTree*) (/mnt/Miecz/godot3.2/scene/main/node.cpp:2560)
[22] SceneTree::init() (/mnt/Miecz/godot3.2/scene/main/scene_tree.cpp:464)
[23] OS_X11::run() (/mnt/Miecz/godot3.2/platform/x11/os_x11.cpp:3628)
[24] godots(main+0x331) [0x16ee467] (/mnt/Miecz/godot3.2/platform/x11/godot_x11.cpp:57)
[25] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0x7f4619ea40b3] (??:0)
[26] godots(_start+0x2e) [0x16ee07e] (??:?)
@angad-k
Copy link
Contributor

angad-k commented Feb 18, 2021

So, there should be a simple null check here, right? :

void MeshInstance3D::_mesh_changed() {
	materials.resize(mesh->get_surface_count());
}

@akien-mga
Copy link
Member

Yes.

@angad-k
Copy link
Contributor

angad-k commented Feb 18, 2021

Okay. Sending a PR

@angad-k
Copy link
Contributor

angad-k commented Feb 18, 2021

Godot 4.0 errors out and doesn't let me call the function itself. Error :

Invalid call. Nonexistent function '_mesh_changed' in base 'MeshInstance3D'.

So, I guess the error is 3.2 specific then...

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