godotengine / godot

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

Comparing misaligned pointer in grid_map_editor_plugin.cpp #34178

Closed qarmin closed 3 years ago

qarmin commented 4 years ago

Godot version: Godot 3.2 beta 3 OS/device including version: Ubuntu 19.04 Issue description: Log from Godot compiled with clang and undefinied behaviour sanitizer(scons p=x11 -j4 use_ubsan=yes use_llvm=yes)

modules/gridmap/grid_map_editor_plugin.cpp:43:16: runtime error: upcast of misaligned address 0xbebebebebebebebe for type 'GridMap', which requires 8 byte alignment
0xbebebebebebebebe: note: pointer points here
<memory cannot be printed>
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior modules/gridmap/grid_map_editor_plugin.cpp:43:16 in 

and log from Valgrind, a little different because this shows using of unitialized variable, but probably is related

Conditional jump or move depends on uninitialised value(s)
   at 0x19764D9: GridMapEditor::_node_removed(Node*) (grid_map_editor_plugin.cpp:43)
   by 0x16DAAA5: MethodBind1<Node*>::call(Object*, Variant const**, int, Variant::CallError&) (method_bind.gen.inc:775)
   by 0x39BB4EF: Object::call(StringName const&, Variant const**, int, Variant::CallError&) (object.cpp:921)
   by 0x39BD452: Object::emit_signal(StringName const&, Variant const**, int) (object.cpp:1218)
   by 0x39BDB8F: Object::emit_signal(StringName const&, Variant const&, Variant const&, Variant const&, Variant const&, Variant const&) (object.cpp:1274)
   by 0x2B28A78: SceneTree::node_removed(Node*) (scene_tree.cpp:114)
   by 0x2AF7D98: Node::_propagate_exit_tree() (node.cpp:307)
   by 0x2AF7C05: Node::_propagate_exit_tree() (node.cpp:294)
   by 0x2AF7C05: Node::_propagate_exit_tree() (node.cpp:294)
   by 0x2B03F2B: Node::_set_tree(SceneTree*) (node.cpp:2551)
   by 0x2AFCB3D: Node::remove_child(Node*) (node.cpp:1261)
   by 0x2AF6D7E: Node::_notification(int) (node.cpp:167)
   by 0x147B35F: Node::_notificationv(int, bool) (node.h:46)
   by 0x147BA9E: CanvasItem::_notificationv(int, bool) (canvas_item.h:166)
   by 0x147C1CE: Control::_notificationv(int, bool) (control.h:48)
   by 0x14965E0: Container::_notificationv(int, bool) (container.h:38)
   by 0x1496D10: BoxContainer::_notificationv(int, bool) (box_container.h:38)
   by 0x1497642: VBoxContainer::_notificationv(int, bool) (box_container.h:81)
   by 0x39BB62A: Object::notification(int, bool) (object.cpp:931)
   by 0x39B8758: Object::_predelete() (object.cpp:386)
   by 0x39C4D45: predelete_handler(Object*) (object.cpp:1987)
   by 0x16BAAD1: void memdelete<Node>(Node*) (memory.h:114)
   by 0x2121EA5: EditorInspector::_clear() (editor_inspector.cpp:1805)
   by 0x211E47C: EditorInspector::update_tree() (editor_inspector.cpp:1431)
   by 0x212662E: EditorInspector::_notification(int) (editor_inspector.cpp:2212)
 Uninitialised value was created by a heap allocation
   at 0x5D837F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x3B01D7D: Memory::alloc_static(unsigned long, bool) (memory.cpp:82)
   by 0x3B01D1E: operator new(unsigned long, char const*) (memory.cpp:42)
   by 0x198614A: GridMapEditorPlugin::GridMapEditorPlugin(EditorNode*) (grid_map_editor_plugin.cpp:1555)
   by 0x15D15E9: EditorPlugin* EditorPlugins::creator<GridMapEditorPlugin>(EditorNode*) (editor_plugin.h:262)
   by 0x218C9F2: EditorPlugins::create(int, EditorNode*) (editor_plugin.h:269)
   by 0x2183E62: EditorNode::EditorNode() (editor_node.cpp:6606)
   by 0x14251D3: Main::start() (main.cpp:1677)
   by 0x13E4957: main (godot_x11.cpp:55)

Steps to reproduce:

  1. Just open empty project
KoBeWi commented 3 years ago

@qarmin Is it still valid in current master?

qarmin commented 3 years ago

Errors still shows with 4.0 and 3.2 branch

akien-mga commented 3 years ago

Fixed by #47044.