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 TileMap.fix_invalid_tiles functions crashes Godot #79845

Closed
qarmin opened this issue Jul 24, 2023 · 0 comments · Fixed by #79851
Closed

Executing TileMap.fix_invalid_tiles functions crashes Godot #79845

qarmin opened this issue Jul 24, 2023 · 0 comments · Fixed by #79851

Comments

@qarmin
Copy link
Contributor

qarmin commented Jul 24, 2023

Godot version

4.2.dev.custom_build. 6588a4a

System information

Ubuntu 22.04 CI

Issue description

When executing

extends Node
func _process(delta):

	var temp_variable5727 = TileMap.new()
	add_child(temp_variable5727)
	temp_variable5727.set_collision_animatable(true)
	temp_variable5727.get_layer_navigation_map(71)
	temp_variable5727.clear()
	temp_variable5727.set_cell(-1, Vector2i(47, 89), 92, Vector2i(3, -31), 66)
	temp_variable5727.fix_invalid_tiles()

Godot crashes:

  ERROR: Index p_layer = 71 is out of bounds ((int)layers.size() = 1).
   at: get_layer_navigation_map (scene/2d/tile_map.cpp:3116)
scene/resources/tile_set.cpp:549:2: runtime error: member access within null pointer of type 'const struct TileSet'
scene/resources/tile_set.cpp:549:2: runtime error: member access within null pointer of type 'const struct TileSet'

================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.2.dev.custom_build (6588a4a29af1621086feac0117d5d4d37af957fd)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] ./godot.linuxbsd.editor.dev.x86_64.san(+0x2dc3c49c) [0x56135538b49c] (/home/runner/work/Qarminer/Qarminer/godot/platform/linuxbsd/crash_handler_linuxbsd.cpp:57)
[2] /lib/x86_64-linux-gnu/libc.so.6(+0x42520) [0x7fbf6cffd520] (??:0)
[3] HashMap<int, Ref<TileSetSource>, HashMapHasherDefault, HashMapComparatorDefault<int>, DefaultTypedAllocator<HashMapElement<int, Ref<TileSetSource> > > >::_lookup_pos(int const&, unsigned int&) const (/home/runner/work/Qarminer/Qarminer/godot/./core/templates/hash_map.h:100)
[4] HashMap<int, Ref<TileSetSource>, HashMapHasherDefault, HashMapComparatorDefault<int>, DefaultTypedAllocator<HashMapElement<int, Ref<TileSetSource> > > >::has(int const&) const (/home/runner/work/Qarminer/Qarminer/godot/./core/templates/hash_map.h:310)
[5] TileSet::get_source(int) const (/home/runner/work/Qarminer/Qarminer/godot/scene/resources/tile_set.cpp:549)
[6] TileMapLayer::fix_invalid_tiles() (/home/runner/work/Qarminer/Qarminer/godot/scene/2d/tile_map.cpp:2276 (discriminator 3))
[7] TileMap::fix_invalid_tiles() (/home/runner/work/Qarminer/Qarminer/godot/scene/2d/tile_map.cpp:3296 (discriminator 3))
[8] void call_with_variant_args_helper<__UnexistingClass>(__UnexistingClass*, void (__UnexistingClass::*)(), Variant const**, Callable::CallError&, IndexSequence<>) (/home/runner/work/Qarminer/Qarminer/godot/./core/variant/binder_common.h:308 (discriminator 4))
[9] void call_with_variant_args_dv<__UnexistingClass>(__UnexistingClass*, void (__UnexistingClass::*)(), Variant const**, int, Callable::CallError&, Vector<Variant> const&) (/home/runner/work/Qarminer/Qarminer/godot/./core/variant/binder_common.h:421)
[10] MethodBindT<>::call(Object*, Variant const**, int, Callable::CallError&) const (/home/runner/work/Qarminer/Qarminer/godot/./core/object/method_bind.h:331)
[11] Object::callp(StringName const&, Variant const**, int, Callable::CallError&) (/home/runner/work/Qarminer/Qarminer/godot/core/object/object.cpp:739 (discriminator 1))
[12] Variant::callp(StringName const&, Variant const**, int, Variant&, Callable::CallError&) (/home/runner/work/Qarminer/Qarminer/godot/core/variant/variant_call.cpp:1174)
[13] GDScriptFunction::call(GDScriptInstance*, Variant const**, int, Callable::CallError&, GDScriptFunction::CallState*) (/home/runner/work/Qarminer/Qarminer/godot/modules/gdscript/gdscript_vm.cpp:1690)
[14] GDScriptInstance::callp(StringName const&, Variant const**, int, Callable::CallError&) (/home/runner/work/Qarminer/Qarminer/godot/modules/gdscript/gdscript.cpp:1892)
[15] bool Node::_gdvirtual__process_call<false>(double) (/home/runner/work/Qarminer/Qarminer/godot/scene/main/node.h:318 (discriminator 5))
[16] Node::_notification(int) (/home/runner/work/Qarminer/Qarminer/godot/scene/main/node.cpp:57)
[17] Node::_notificationv(int, bool) (/home/runner/work/Qarminer/Qarminer/godot/./scene/main/node.h:49 (discriminator 14))
[18] Object::notification(int, bool) (/home/runner/work/Qarminer/Qarminer/godot/core/object/object.cpp:798)
[19] SceneTree::_process_group(SceneTree::ProcessGroup*, bool) (/home/runner/work/Qarminer/Qarminer/godot/scene/main/scene_tree.cpp:944)
[20] SceneTree::_process(bool) (/home/runner/work/Qarminer/Qarminer/godot/scene/main/scene_tree.cpp:1016 (discriminator 2))
[21] SceneTree::process(double) (/home/runner/work/Qarminer/Qarminer/godot/scene/main/scene_tree.cpp:510 (discriminator 4))
[22] Main::iteration() (/home/runner/work/Qarminer/Qarminer/godot/main/main.cpp:3434)
[23] OS_LinuxBSD::run() (/home/runner/work/Qarminer/Qarminer/godot/platform/linuxbsd/os_linuxbsd.cpp:912)
[24] ./godot.linuxbsd.editor.dev.x86_64.san(main+0x58f) [0x56135538ae48] (/home/runner/work/Qarminer/Qarminer/godot/platform/linuxbsd/godot_linuxbsd.cpp:76)
[25] /lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x7fbf6cfe4d90] (??:0)
[26] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80) [0x7fbf6cfe4e40] (??:0)
[27] ./godot.linuxbsd.editor.dev.x86_64.san(_start+0x25) [0x56135538a7f5] (??:?)

This example was found by Godot fuzzer - Qarminer, so it is quite unlikelly that this code could be used in real project, but still this should be handled gracefully.

Memory leaks or asan backtraces are visibe when using Godot build with sanitizers support - https://github.com/qarmin/GodotBuilds/actions (linux -> linux-editor-sanitizers)

Steps to reproduce

Above

Minimal reproduction project

Above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants