godotengine / godot

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

Memory leaks with multithreading #87382

Closed qarmin closed 4 months ago

qarmin commented 8 months ago

Tested versions

4.3.dev.custom_build. 7827c8e37

System information

Ubuntu 22.04 CI Lavapipe

Issue description

Headless

extends Node
func _process(delta):
    var temp_variable40299 = RandomNumberGenerator.new()
    temp_variable40299.get_class()

cause leak

Godot Engine v4.3.dev.custom_build.7827c8e37 - https://godotengine.org
WARNING: The Multi-Threaded rendering thread model is experimental, and has known issues which can lead to project crashes. Use the Single-Safe option in the project settings instead.
     at: setup2 (main/main.cpp:2498)
WARNING: Rendering thread not supported by this display server.
     at: release_rendering_thread (servers/display_server.cpp:566)
WARNING: Rendering thread not supported by this display server.
     at: make_rendering_thread (servers/display_server.cpp:570)
WARNING: ObjectDB instances leaked at exit (run with --verbose for details).
     at: cleanup (core/object/object.cpp:2204)
=================================================================
==18483==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 65552 byte(s) in 1 object(s) allocated from:
    #0 0x7f98738b4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x558216005b81 in Memory::alloc_static(unsigned long, bool) core/os/memory.cpp:75
    #2 0x558202a5128a in Error CowData<char32_t>::resize<false>(int) core/templates/cowdata.h:291
    #3 0x55820300f6b5 in String::resize(int) core/string/ustring.h:218
    #4 0x558212c086ac in ShaderPreprocessor::vector_to_string(LocalVector<char32_t, unsigned int, false, false> const&, int, int) servers/rendering/shader_preprocessor.cpp:361
    #5 0x558212c1e766 in ShaderPreprocessor::preprocess(ShaderPreprocessor::State*, String const&, String&) servers/rendering/shader_preprocessor.cpp:1299
    #6 0x558212c1ec23 in ShaderPreprocessor::preprocess(String const&, String const&, String&, String*, List<ShaderPreprocessor::FilePosition, DefaultAllocator>*, List<ShaderPreprocessor::Region, DefaultAllocator>*, HashSet<Ref<ShaderInclude>, HashMapHasherDefault, HashMapComparatorDefault<Ref<ShaderInclude> > >*, List<ScriptLanguage::CodeCompletionOption, DefaultAllocator>*, List<ScriptLanguage::CodeCompletionOption, DefaultAllocator>*, void (*)(List<ScriptLanguage::CodeCompletionOption, DefaultAllocator>*)) servers/rendering/shader_preprocessor.cpp:1310
    #7 0x55820ff04600 in Shader::set_code(String const&) scene/resources/shader.cpp:82
    #8 0x55820bb85879 in ColorPicker::init_shaders() scene/gui/color_picker.cpp:191
    #9 0x55820adc1eb5 in register_scene_types() scene/register_scene_types.cpp:1188
    #10 0x5581fcc38749 in Main::setup2() main/main.cpp:2810
    #11 0x5581fcc258dd in Main::setup(char const*, int, char**, bool) main/main.cpp:2238
    #12 0x5581fc93baac in main platform/linuxbsd/godot_linuxbsd.cpp:62
    #13 0x7f9872c29d8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
Direct leak of 40848 byte(s) in 74 object(s) allocated from:
    #0 0x7f98738b4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x558216005b81 in Memory::alloc_static(unsigned long, bool) core/os/memory.cpp:75
    #2 0x558216005a92 in operator new(unsigned long, char const*) core/os/memory.cpp:40
    #3 0x558211024af4 in generate_icon scene/theme/default_theme.cpp:83
    #4 0x55821102be80 in fill_default_theme(Ref<Theme>&, Ref<Font> const&, Ref<Font> const&, Ref<Font> const&, Ref<Font> const&, Ref<Texture2D>&, Ref<StyleBox>&, float) scene/theme/default_theme.cpp:145
    #5 0x5582110a9741 in make_default_theme(float, Ref<Font>, TextServer::SubpixelPositioning, TextServer::Hinting, TextServer::FontAntialiasing, bool, bool) scene/theme/default_theme.cpp:1236
    #6 0x558210fb75af in ThemeDB::initialize_theme() scene/theme/theme_db.cpp:89
    #7 0x5581fcc3b1a9 in Main::setup2() main/main.cpp:2881
    #8 0x5581fcc258dd in Main::setup(char const*, int, char**, bool) main/main.cpp:2238
    #9 0x5581fc93baac in main platform/linuxbsd/godot_linuxbsd.cpp:62
    #10 0x7f9872c29d8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
Direct leak of 4112 byte(s) in 1 object(s) allocated from:
    #0 0x7f98738b4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x558216005b81 in Memory::alloc_static(unsigned long, bool) core/os/memory.cpp:75
    #2 0x558202a5128a in Error CowData<char32_t>::resize<false>(int) core/templates/cowdata.h:291
    #3 0x55820300f6b5 in String::resize(int) core/string/ustring.h:218
    #4 0x558212c086ac in ShaderPreprocessor::vector_to_string(LocalVector<char32_t, unsigned int, false, false> const&, int, int) servers/rendering/shader_preprocessor.cpp:361
    #5 0x558212c1e766 in ShaderPreprocessor::preprocess(ShaderPreprocessor::State*, String const&, String&) servers/rendering/shader_preprocessor.cpp:1299
    #6 0x558212c1ec23 in ShaderPreprocessor::preprocess(String const&, String const&, String&, String*, List<ShaderPreprocessor::FilePosition, DefaultAllocator>*, List<ShaderPreprocessor::Region, DefaultAllocator>*, HashSet<Ref<ShaderInclude>, HashMapHasherDefault, HashMapComparatorDefault<Ref<ShaderInclude> > >*, List<ScriptLanguage::CodeCompletionOption, DefaultAllocator>*, List<ScriptLanguage::CodeCompletionOption, DefaultAllocator>*, void (*)(List<ScriptLanguage::CodeCompletionOption, DefaultAllocator>*)) servers/rendering/shader_preprocessor.cpp:1310
    #7 0x55820ff04600 in Shader::set_code(String const&) scene/resources/shader.cpp:82
    #8 0x55820bb85678 in ColorPicker::init_shaders() scene/gui/color_picker.cpp:166
    #9 0x55820adc1eb5 in register_scene_types() scene/register_scene_types.cpp:1188
    #10 0x5581fcc38749 in Main::setup2() main/main.cpp:2810
    #11 0x5581fcc258dd in Main::setup(char const*, int, char**, bool) main/main.cpp:2238
    #12 0x5581fc93baac in main platform/linuxbsd/godot_linuxbsd.cpp:62
    #13 0x7f9872c29d8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
Direct leak of 4112 byte(s) in 1 object(s) allocated from:
    #0 0x7f98738b4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x558216005b81 in Memory::alloc_static(unsigned long, bool) core/os/memory.cpp:75
    #2 0x558202a5128a in Error CowData<char32_t>::resize<false>(int) core/templates/cowdata.h:291
    #3 0x55820300f6b5 in String::resize(int) core/string/ustring.h:218
    #4 0x558212c086ac in ShaderPreprocessor::vector_to_string(LocalVector<char32_t, unsigned int, false, false> const&, int, int) servers/rendering/shader_preprocessor.cpp:361
    #5 0x558212c1e766 in ShaderPreprocessor::preprocess(ShaderPreprocessor::State*, String const&, String&) servers/rendering/shader_preprocessor.cpp:1299
    #6 0x558212c1ec23 in ShaderPreprocessor::preprocess(String const&, String const&, String&, String*, List<ShaderPreprocessor::FilePosition, DefaultAllocator>*, List<ShaderPreprocessor::Region, DefaultAllocator>*, HashSet<Ref<ShaderInclude>, HashMapHasherDefault, HashMapComparatorDefault<Ref<ShaderInclude> > >*, List<ScriptLanguage::CodeCompletionOption, DefaultAllocator>*, List<ScriptLanguage::CodeCompletionOption, DefaultAllocator>*, void (*)(List<ScriptLanguage::CodeCompletionOption, DefaultAllocator>*)) servers/rendering/shader_preprocessor.cpp:1310
    #7 0x55820ff04600 in Shader::set_code(String const&) scene/resources/shader.cpp:82
    #8 0x55820bb854e5 in ColorPicker::init_shaders() scene/gui/color_picker.cpp:142
    #9 0x55820adc1eb5 in register_scene_types() scene/register_scene_types.cpp:1188
    #10 0x5581fcc38749 in Main::setup2() main/main.cpp:2810
    #11 0x5581fcc258dd in Main::setup(char const*, int, char**, bool) main/main.cpp:2238
    #12 0x5581fc93baac in main platform/linuxbsd/godot_linuxbsd.cpp:62
    #13 0x7f9872c29d8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
Direct leak of 2064 byte(s) in 1 object(s) allocated from:
    #0 0x7f98738b4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x558216005b81 in Memory::alloc_static(unsigned long, bool) core/os/memory.cpp:75
    #2 0x558202a5128a in Error CowData<char32_t>::resize<false>(int) core/templates/cowdata.h:291
    #3 0x55820300f6b5 in String::resize(int) core/string/ustring.h:218
    #4 0x558212c086ac in ShaderPreprocessor::vector_to_string(LocalVector<char32_t, unsigned int, false, false> const&, int, int) servers/rendering/shader_preprocessor.cpp:361
    #5 0x558212c1e766 in ShaderPreprocessor::preprocess(ShaderPreprocessor::State*, String const&, String&) servers/rendering/shader_preprocessor.cpp:1299
    #6 0x558212c1ec23 in ShaderPreprocessor::preprocess(String const&, String const&, String&, String*, List<ShaderPreprocessor::FilePosition, DefaultAllocator>*, List<ShaderPreprocessor::Region, DefaultAllocator>*, HashSet<Ref<ShaderInclude>, HashMapHasherDefault, HashMapComparatorDefault<Ref<ShaderInclude> > >*, List<ScriptLanguage::CodeCompletionOption, DefaultAllocator>*, List<ScriptLanguage::CodeCompletionOption, DefaultAllocator>*, void (*)(List<ScriptLanguage::CodeCompletionOption, DefaultAllocator>*)) servers/rendering/shader_preprocessor.cpp:1310
    #7 0x55820ff04600 in Shader::set_code(String const&) scene/resources/shader.cpp:82
    #8 0x55820bf65e8f in GraphEdit::init_shaders() scene/gui/graph_edit.cpp:220
    #9 0x55820adc1eba in register_scene_types() scene/register_scene_types.cpp:1189
    #10 0x5581fcc38749 in Main::setup2() main/main.cpp:2810
    #11 0x5581fcc258dd in Main::setup(char const*, int, char**, bool) main/main.cpp:2238
    #12 0x5581fc93baac in main platform/linuxbsd/godot_linuxbsd.cpp:62
    #13 0x7f9872c29d8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
Direct leak of 1104 byte(s) in 2 object(s) allocated from:
    #0 0x7f98738b4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x558216005b81 in Memory::alloc_static(unsigned long, bool) core/os/memory.cpp:75
    #2 0x558216005a92 in operator new(unsigned long, char const*) core/os/memory.cpp:40
    #3 0x5581fcabff63 in Ref<Image>::instantiate() core/object/ref_counted.h:216
    #4 0x55820f624a36 in GradientTexture2D::_update() scene/resources/gradient_texture.cpp:235
    #5 0x55820f62ff13 in GradientTexture2D::update_now() scene/resources/gradient_texture.cpp:416
    #6 0x55820f658ba2 in void call_with_variant_args_helper<GradientTexture2D>(GradientTexture2D*, void (GradientTexture2D::*)(), Variant const**, Callable::CallError&, IndexSequence<>) core/variant/binder_common.h:303
    #7 0x55820f653302 in void call_with_variant_args<GradientTexture2D>(GradientTexture2D*, void (GradientTexture2D::*)(), Variant const**, int, Callable::CallError&) core/variant/binder_common.h:417
    #8 0x55820f64d260 in CallableCustomMethodPointer<GradientTexture2D>::call(Variant const**, int, Variant&, Callable::CallError&) const core/object/callable_method_pointer.h:98
    #9 0x558216ca3718 in Callable::callp(Variant const**, int, Variant&, Callable::CallError&) const core/variant/callable.cpp:56
    #10 0x55821798bde5 in CallQueue::_call_function(Callable const&, Variant const*, int, bool) core/object/message_queue.cpp:221
    #11 0x55821798fdbe in CallQueue::flush() core/object/message_queue.cpp:326
    #12 0x55820b4426a3 in SceneTree::physics_process(double) scene/main/scene_tree.cpp:471
    #13 0x5581fcc57ca0 in Main::iteration() main/main.cpp:3752
    #14 0x5581fc95d6e9 in OS_LinuxBSD::run() platform/linuxbsd/os_linuxbsd.cpp:933
    #15 0x5581fc93bc8b in main platform/linuxbsd/godot_linuxbsd.cpp:74
    #16 0x7f9872c29d8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
Indirect leak of 83104 byte(s) in 74 object(s) allocated from:
    #0 0x7f98738b4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x558216005b81 in Memory::alloc_static(unsigned long, bool) core/os/memory.cpp:75
    #2 0x5581fcae4bfe in Error CowData<unsigned char>::resize<false>(int) core/templates/cowdata.h:291
    #3 0x5581fcac07b1 in Vector<unsigned char>::resize(int) core/templates/vector.h:94
    #4 0x558202cf677c in ImageLoaderSVG::create_image_from_utf8_buffer(Ref<Image>, unsigned char const*, int, float, bool) modules/svg/image_loader_svg.cpp:135
    #5 0x558202cf6fa1 in ImageLoaderSVG::create_image_from_utf8_buffer(Ref<Image>, Vector<unsigned char> const&, float, bool) modules/svg/image_loader_svg.cpp:156
    #6 0x558202cf737b in ImageLoaderSVG::create_image_from_string(Ref<Image>, String, float, bool, HashMap<Color, Color, HashMapHasherDefault, HashMapComparatorDefault<Color>, DefaultTypedAllocator<HashMapElement<Color, Color> > > const&) modules/svg/image_loader_svg.cpp:168
    #7 0x558211024e71 in generate_icon scene/theme/default_theme.cpp:91
    #8 0x55821102be80 in fill_default_theme(Ref<Theme>&, Ref<Font> const&, Ref<Font> const&, Ref<Font> const&, Ref<Font> const&, Ref<Texture2D>&, Ref<StyleBox>&, float) scene/theme/default_theme.cpp:145
    #9 0x5582110a9741 in make_default_theme(float, Ref<Font>, TextServer::SubpixelPositioning, TextServer::Hinting, TextServer::FontAntialiasing, bool, bool) scene/theme/default_theme.cpp:1236
    #10 0x558210fb75af in ThemeDB::initialize_theme() scene/theme/theme_db.cpp:89
    #11 0x5581fcc3b1a9 in Main::setup2() main/main.cpp:2881
    #12 0x5581fcc258dd in Main::setup(char const*, int, char**, bool) main/main.cpp:2238
    #13 0x5581fc93baac in main platform/linuxbsd/godot_linuxbsd.cpp:62
    #14 0x7f9872c29d8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
Indirect leak of 65568 byte(s) in 2 object(s) allocated from:
    #0 0x7f98738b4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x558216005b81 in Memory::alloc_static(unsigned long, bool) core/os/memory.cpp:75
    #2 0x5581fcae4bfe in Error CowData<unsigned char>::resize<false>(int) core/templates/cowdata.h:291
    #3 0x5581fcac07b1 in Vector<unsigned char>::resize(int) core/templates/vector.h:94
    #4 0x55820f626822 in GradientTexture2D::_update() scene/resources/gradient_texture.cpp:253
    #5 0x55820f62ff13 in GradientTexture2D::update_now() scene/resources/gradient_texture.cpp:416
    #6 0x55820f658ba2 in void call_with_variant_args_helper<GradientTexture2D>(GradientTexture2D*, void (GradientTexture2D::*)(), Variant const**, Callable::CallError&, IndexSequence<>) core/variant/binder_common.h:303
    #7 0x55820f653302 in void call_with_variant_args<GradientTexture2D>(GradientTexture2D*, void (GradientTexture2D::*)(), Variant const**, int, Callable::CallError&) core/variant/binder_common.h:417
    #8 0x55820f64d260 in CallableCustomMethodPointer<GradientTexture2D>::call(Variant const**, int, Variant&, Callable::CallError&) const core/object/callable_method_pointer.h:98
    #9 0x558216ca3718 in Callable::callp(Variant const**, int, Variant&, Callable::CallError&) const core/variant/callable.cpp:56
    #10 0x55821798bde5 in CallQueue::_call_function(Callable const&, Variant const*, int, bool) core/object/message_queue.cpp:221
    #11 0x55821798fdbe in CallQueue::flush() core/object/message_queue.cpp:326
    #12 0x55820b4426a3 in SceneTree::physics_process(double) scene/main/scene_tree.cpp:471
    #13 0x5581fcc57ca0 in Main::iteration() main/main.cpp:3752
    #14 0x5581fc95d6e9 in OS_LinuxBSD::run() platform/linuxbsd/os_linuxbsd.cpp:933
    #15 0x5581fc93bc8b in main platform/linuxbsd/godot_linuxbsd.cpp:74
    #16 0x7f9872c29d8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
SUMMARY: AddressSanitizer: 266464 byte(s) leaked in 156 allocation(s).

Vulkan

Godot Engine v4.3.dev.custom_build.7827c8e37 - https://godotengine.org
WARNING: GENERAL - Message Id Number: 0 | Message Id Name: Loader Message
    terminator_CreateInstance: Failed to CreateInstance in ICD 0.  Skipping ICD.
    Objects - 1
        Object[0] - VK_OBJECT_TYPE_INSTANCE, Handle 108370614997504
     at: _debug_messenger_callback (drivers/vulkan/vulkan_context.cpp:264)
WARNING: GENERAL - Message Id Number: 0 | Message Id Name: Loader Message
    terminator_CreateInstance: Failed to CreateInstance in ICD 4.  Skipping ICD.
    Objects - 1
        Object[0] - VK_OBJECT_TYPE_INSTANCE, Handle 108370614997504
     at: _debug_messenger_callback (drivers/vulkan/vulkan_context.cpp:264)
Vulkan API 1.3.255 - Forward Mobile - Using Vulkan Device #0: Unknown - llvmpipe (LLVM 15.0.7, 256 bits)
WARNING: Invalid/corrupt pipelines cache.
     at: pipeline_cache_create (drivers/vulkan/rendering_device_driver_vulkan.cpp:2209)
WARNING: The Multi-Threaded rendering thread model is experimental, and has known issues which can lead to project crashes. Use the Single-Safe option in the project settings instead.
     at: setup2 (main/main.cpp:2498)
=================================================================
==20704==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 65552 byte(s) in 1 object(s) allocated from:
    #0 0x7f52afcb4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x55cf50a6fb81 in Memory::alloc_static(unsigned long, bool) core/os/memory.cpp:75
    #2 0x55cf3d4bb28a in Error CowData<char32_t>::resize<false>(int) core/templates/cowdata.h:291
    #3 0x55cf3da796b5 in String::resize(int) core/string/ustring.h:218
    #4 0x55cf4d6726ac in ShaderPreprocessor::vector_to_string(LocalVector<char32_t, unsigned int, false, false> const&, int, int) servers/rendering/shader_preprocessor.cpp:361
    #5 0x55cf4d688766 in ShaderPreprocessor::preprocess(ShaderPreprocessor::State*, String const&, String&) servers/rendering/shader_preprocessor.cpp:1299
    #6 0x55cf4d688c23 in ShaderPreprocessor::preprocess(String const&, String const&, String&, String*, List<ShaderPreprocessor::FilePosition, DefaultAllocator>*, List<ShaderPreprocessor::Region, DefaultAllocator>*, HashSet<Ref<ShaderInclude>, HashMapHasherDefault, HashMapComparatorDefault<Ref<ShaderInclude> > >*, List<ScriptLanguage::CodeCompletionOption, DefaultAllocator>*, List<ScriptLanguage::CodeCompletionOption, DefaultAllocator>*, void (*)(List<ScriptLanguage::CodeCompletionOption, DefaultAllocator>*)) servers/rendering/shader_preprocessor.cpp:1310
    #7 0x55cf4a96e600 in Shader::set_code(String const&) scene/resources/shader.cpp:82
    #8 0x55cf465ef879 in ColorPicker::init_shaders() scene/gui/color_picker.cpp:191
    #9 0x55cf4582beb5 in register_scene_types() scene/register_scene_types.cpp:1188
    #10 0x55cf376a2749 in Main::setup2() main/main.cpp:2810
    #11 0x55cf3768f8dd in Main::setup(char const*, int, char**, bool) main/main.cpp:2238
    #12 0x55cf373a5aac in main platform/linuxbsd/godot_linuxbsd.cpp:62
    #13 0x7f52af029d8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
Direct leak of 4112 byte(s) in 1 object(s) allocated from:
    #0 0x7f52afcb4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x55cf50a6fb81 in Memory::alloc_static(unsigned long, bool) core/os/memory.cpp:75
    #2 0x55cf3d4bb28a in Error CowData<char32_t>::resize<false>(int) core/templates/cowdata.h:291
    #3 0x55cf3da796b5 in String::resize(int) core/string/ustring.h:218
    #4 0x55cf4d6726ac in ShaderPreprocessor::vector_to_string(LocalVector<char32_t, unsigned int, false, false> const&, int, int) servers/rendering/shader_preprocessor.cpp:361
    #5 0x55cf4d688766 in ShaderPreprocessor::preprocess(ShaderPreprocessor::State*, String const&, String&) servers/rendering/shader_preprocessor.cpp:1299
    #6 0x55cf4d688c23 in ShaderPreprocessor::preprocess(String const&, String const&, String&, String*, List<ShaderPreprocessor::FilePosition, DefaultAllocator>*, List<ShaderPreprocessor::Region, DefaultAllocator>*, HashSet<Ref<ShaderInclude>, HashMapHasherDefault, HashMapComparatorDefault<Ref<ShaderInclude> > >*, List<ScriptLanguage::CodeCompletionOption, DefaultAllocator>*, List<ScriptLanguage::CodeCompletionOption, DefaultAllocator>*, void (*)(List<ScriptLanguage::CodeCompletionOption, DefaultAllocator>*)) servers/rendering/shader_preprocessor.cpp:1310
    #7 0x55cf4a96e600 in Shader::set_code(String const&) scene/resources/shader.cpp:82
    #8 0x55cf465ef678 in ColorPicker::init_shaders() scene/gui/color_picker.cpp:166
    #9 0x55cf4582beb5 in register_scene_types() scene/register_scene_types.cpp:1188
    #10 0x55cf376a2749 in Main::setup2() main/main.cpp:2810
    #11 0x55cf3768f8dd in Main::setup(char const*, int, char**, bool) main/main.cpp:2238
    #12 0x55cf373a5aac in main platform/linuxbsd/godot_linuxbsd.cpp:62
    #13 0x7f52af029d8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)

GLES3

Godot Engine v4.3.dev.custom_build.7827c8e37 - https://godotengine.org
WARNING: Could not set V-Sync mode. V-Sync is not supported.
     at: set_use_vsync (platform/linuxbsd/x11/gl_manager_x11.cpp:374)
WARNING: The Multi-Threaded rendering thread model is experimental, and has known issues which can lead to project crashes. Use the Single-Safe option in the project settings instead.
     at: setup2 (main/main.cpp:2498)
servers/rendering/shader_compiler.h:89:9: runtime error: load of value 1380403859, which is not a valid value for type 'TextureFilter'
servers/rendering/shader_compiler.h:89:9: runtime error: load of value 22044, which is not a valid value for type 'TextureRepeat'
servers/rendering/shader_compiler.h:89:9: runtime error: load of value 1380403859, which is not a valid value for type 'TextureFilter'
servers/rendering/shader_compiler.h:89:9: runtime error: load of value 22044, which is not a valid value for type 'TextureRepeat'
OpenGL API  - Compatibility - Using Device:  - 
ERROR: trying to allocate texture with name Texture 2D but ID already used by Texture 2D: 0
   at: texture_allocated_data (drivers/gles3/storage/utilities.h:117)
ERROR: trying to allocate texture with name Texture 2D but ID already used by Texture 2D: 0
   at: texture_allocated_data (drivers/gles3/storage/utilities.h:117)
   ERROR: Texture cache is not empty. There may be an additional texture leak of 5356884 bytes.
   at: ~Utilities (drivers/gles3/storage/utilities.cpp:84)
WARNING: ObjectDB instances leaked at exit (run with --verbose for details).
     at: cleanup (core/object/object.cpp:2204)
Direct leak of 65552 byte(s) in 1 object(s) allocated from:
    #0 0x7fd1b2eb4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x561c52474b81 in Memory::alloc_static(unsigned long, bool) core/os/memory.cpp:75
    #2 0x561c3eec028a in Error CowData<char32_t>::resize<false>(int) core/templates/cowdata.h:291
    #3 0x561c3f47e6b5 in String::resize(int) core/string/ustring.h:218
    #4 0x561c4f0776ac in ShaderPreprocessor::vector_to_string(LocalVector<char32_t, unsigned int, false, false> const&, int, int) servers/rendering/shader_preprocessor.cpp:361
    #5 0x561c4f08d766 in ShaderPreprocessor::preprocess(ShaderPreprocessor::State*, String const&, String&) servers/rendering/shader_preprocessor.cpp:1299
    #6 0x561c4f08dc23 in ShaderPreprocessor::preprocess(String const&, String const&, String&, String*, List<ShaderPreprocessor::FilePosition, DefaultAllocator>*, List<ShaderPreprocessor::Region, DefaultAllocator>*, HashSet<Ref<ShaderInclude>, HashMapHasherDefault, HashMapComparatorDefault<Ref<ShaderInclude> > >*, List<ScriptLanguage::CodeCompletionOption, DefaultAllocator>*, List<ScriptLanguage::CodeCompletionOption, DefaultAllocator>*, void (*)(List<ScriptLanguage::CodeCompletionOption, DefaultAllocator>*)) servers/rendering/shader_preprocessor.cpp:1310
    #7 0x561c4c373600 in Shader::set_code(String const&) scene/resources/shader.cpp:82
    #8 0x561c47ff4879 in ColorPicker::init_shaders() scene/gui/color_picker.cpp:191
    #9 0x561c47230eb5 in register_scene_types() scene/register_scene_types.cpp:1188
    #10 0x561c390a7749 in Main::setup2() main/main.cpp:2810
    #11 0x561c390948dd in Main::setup(char const*, int, char**, bool) main/main.cpp:2238
    #12 0x561c38daaaac in main platform/linuxbsd/godot_linuxbsd.cpp:62
    #13 0x7fd1b2229d8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)

Steps to reproduce

Run minimal project - contains inside project.godot

[rendering]
threads/thread_model=2
driver/threads/thread_model=2

Minimal reproduction project (MRP)

Untitled Folder 2.zip - empty project with only one node and set multithread settings

akien-mga commented 4 months ago

How should Godot be compiled exactly to reproduce the issue? And how to run/quit the project to make sure to get leak sanitizer reports?

I tried a build with use_lsan=yes from GCC on Linux, and running this project then closing the window doesn't seem to report leaks. Maybe it's fixed already?

akien-mga commented 4 months ago

Actually I was running the wrong binary :upside_down_face:

My LSAN binary actually seems to segfault on current master, with what seems like a stack overflow:

Thread 1 "godot.linuxbsd." received signal SIGSEGV, Segmentation fault.
0x00007ffff7fdb744 in update_get_addr (ti=0x7ffff7a76d90, gen=2) at ../elf/dl-tls.c:916
warning: 916    ../elf/dl-tls.c: No such file or directory
Missing separate debuginfos, use: dnf debuginfo-install bzip2-libs-1.0.8-18.fc40.x86_64 fontconfig-2.15.0-4.fc40.x86_64 freetype-2.13.2-5.fc40.x86_64 glib2-2.80.0-1.fc40.x86_64 glibc-2.39-8.fc40.x86_64 graphite2-1.3.14-15.fc40.x86_64 harfbuzz-8.3.0-5.fc40.x86_64 libbrotli-1.1.0-3.fc40.x86_64 libcap-2.69-8.fc40.x86_64 libgcc-14.0.1-0.15.fc40.x86_64 liblsan-14.0.1-0.15.fc40.x86_64 libpng-1.6.40-3.fc40.x86_64 libstdc++-14.0.1-0.15.fc40.x86_64 libxml2-2.12.6-1.fc40.x86_64 pcre2-10.42-2.fc40.2.x86_64 systemd-libs-255.4-1.fc40.x86_64 xz-libs-5.4.6-3.fc40.x86_64 zlib-ng-compat-2.1.6-2.fc40.x86_64
(gdb) bt
#0  0x00007ffff7fdb744 in update_get_addr (ti=0x7ffff7a76d90, gen=2) at ../elf/dl-tls.c:916
#1  0x00007ffff7fde4ec in __tls_get_addr () at ../sysdeps/x86_64/tls_get_addr.S:55
#2  0x00007ffff7a0f7b4 in __lsan::GetAllocatorCache() () from /lib64/liblsan.so.0
#3  0x00007ffff7a12b22 in __lsan::lsan_free(void*) () from /lib64/liblsan.so.0
#4  0x00007ffff7fdb67b in free (ptr=<optimized out>) at ../include/rtld-malloc.h:50
#5  _dl_update_slotinfo (req_modid=2, new_gen=2) at ../elf/dl-tls.c:822
#6  0x00007ffff7fdb754 in update_get_addr (ti=0x7ffff7a76d90, gen=<optimized out>) at ../elf/dl-tls.c:916
#7  0x00007ffff7fde4ec in __tls_get_addr () at ../sysdeps/x86_64/tls_get_addr.S:55
#8  0x00007ffff7a0f7b4 in __lsan::GetAllocatorCache() () from /lib64/liblsan.so.0
#9  0x00007ffff7a12b22 in __lsan::lsan_free(void*) () from /lib64/liblsan.so.0
#10 0x00007ffff7fdb67b in free (ptr=<optimized out>) at ../include/rtld-malloc.h:50
#11 _dl_update_slotinfo (req_modid=2, new_gen=2) at ../elf/dl-tls.c:822
#12 0x00007ffff7fdb754 in update_get_addr (ti=0x7ffff7a76d90, gen=<optimized out>) at ../elf/dl-tls.c:916
#13 0x00007ffff7fde4ec in __tls_get_addr () at ../sysdeps/x86_64/tls_get_addr.S:55
#14 0x00007ffff7a0f7b4 in __lsan::GetAllocatorCache() () from /lib64/liblsan.so.0
#15 0x00007ffff7a12b22 in __lsan::lsan_free(void*) () from /lib64/liblsan.so.0
#16 0x00007ffff7fdb67b in free (ptr=<optimized out>) at ../include/rtld-malloc.h:50
#17 _dl_update_slotinfo (req_modid=2, new_gen=2) at ../elf/dl-tls.c:822
#18 0x00007ffff7fdb754 in update_get_addr (ti=0x7ffff7a76d90, gen=<optimized out>) at ../elf/dl-tls.c:916
#19 0x00007ffff7fde4ec in __tls_get_addr () at ../sysdeps/x86_64/tls_get_addr.S:55
#20 0x00007ffff7a0f7b4 in __lsan::GetAllocatorCache() () from /lib64/liblsan.so.0
#21 0x00007ffff7a12b22 in __lsan::lsan_free(void*) () from /lib64/liblsan.so.0
#22 0x00007ffff7fdb67b in free (ptr=<optimized out>) at ../include/rtld-malloc.h:50
#23 _dl_update_slotinfo (req_modid=2, new_gen=2) at ../elf/dl-tls.c:822
--Type <RET> for more, q to quit, c to continue without paging--
akien-mga commented 4 months ago

So this time I made a build with:

scons use_lsan=yes use_asan=yes dev_build=yes

from ab01dd0310c8b4d73cbd8cff00f8074a37351e47.

ASAN reports a use after free when running this project:

$ ~/Godot/godot/bin/godot.linuxbsd.editor.dev.x86_64.san 
Godot Engine v4.3.dev.custom_build.55b8724bd (2024-05-07 14:49:50 UTC) - https://godotengine.org
Vulkan 1.3.274 - Forward+ - Using Device #1: AMD - AMD Radeon RX 7600M XT (RADV NAVI33)
WARNING: The Multi-Threaded rendering thread model is experimental. Feel free to try it since it will eventually become a stable feature.
However, bear in mind that at the moment it can lead to project crashes or instability.
So, unless you want to test the engine, use the Single-Safe option in the project settings instead.
     at: setup2 (main/main.cpp:2738)

ERROR: Parameter "shader" is null.
   at: uniform_set_create (servers/rendering/rendering_device.cpp:2535)
ERROR: Parameter "pipeline" is null.
   at: draw_list_bind_render_pipeline (servers/rendering/rendering_device.cpp:3545)
ERROR: Parameter "index_array" is null.
   at: draw_list_bind_index_array (servers/rendering/rendering_device.cpp:3697)
ERROR: Parameter "uniform_set" is null.
   at: draw_list_bind_uniform_set (servers/rendering/rendering_device.cpp:3633)
ERROR: This render pipeline requires (0) bytes of push constant data, supplied: (64)
   at: draw_list_set_push_constant (servers/rendering/rendering_device.cpp:3736)
ERROR: No render pipeline was set before attempting to draw.
   at: draw_list_draw (servers/rendering/rendering_device.cpp:3755)
=================================================================
==244351==ERROR: AddressSanitizer: heap-use-after-free on address 0x512000bb7318 at pc 0x00000ba5c1db bp 0x7fa4cddfefd0 sp 0x7fa4cddfefc8
READ of size 1 at 0x512000bb7318 thread T2
    #0 0xba5c1da in CommandQueueMT::_flush() core/templates/command_queue_mt.h:366
    #1 0xba5c441 in CommandQueueMT::flush_all() core/templates/command_queue_mt.h:409
    #2 0xba5abdb in RenderingServerDefault::_thread_loop() servers/rendering/rendering_server_default.cpp:347
    #3 0xbb28411 in void call_with_variant_args_helper<RenderingServerDefault>(RenderingServerDefault*, void (RenderingServerDefault::*)(), Variant const**, Callable::CallError&, IndexSequence<>) core/variant/binder_common.h:304
    #4 0xbb28176 in void call_with_variant_args<RenderingServerDefault>(RenderingServerDefault*, void (RenderingServerDefault::*)(), Variant const**, int, Callable::CallError&) core/variant/binder_common.h:418
    #5 0xbb01120 in CallableCustomMethodPointer<RenderingServerDefault>::call(Variant const**, int, Variant&, Callable::CallError&) const core/object/callable_method_pointer.h:103
    #6 0xd2186ad in Callable::callp(Variant const**, int, Variant&, Callable::CallError&) const core/variant/callable.cpp:57
    #7 0x2bd0293 in Variant Callable::call<>() const core/variant/variant.h:872
    #8 0xda38af2 in WorkerThreadPool::_process_task(WorkerThreadPool::Task*) core/object/worker_thread_pool.cpp:137
    #9 0xda3931e in WorkerThreadPool::_thread_function(void*) core/object/worker_thread_pool.cpp:196
    #10 0xcc77c19 in Thread::callback(unsigned long, Thread::Settings const&, void (*)(void*), void*) core/os/thread.cpp:64
    #11 0xcc79052 in void std::__invoke_impl<void, void (*)(unsigned long, Thread::Settings const&, void (*)(void*), void*), unsigned long, Thread::Settings, void (*)(void*), void*>(std::__invoke_other, void (*&&)(unsigned long, Thread::Settings const&, void (*)(void*), void*), unsigned long&&, Thread::Settings&&, void (*&&)(void*), void*&&) /usr/include/c++/14/bits/invoke.h:61
    #12 0xcc78e9b in std::__invoke_result<void (*)(unsigned long, Thread::Settings const&, void (*)(void*), void*), unsigned long, Thread::Settings, void (*)(void*), void*>::type std::__invoke<void (*)(unsigned long, Thread::Settings const&, void (*)(void*), void*), unsigned long, Thread::Settings, void (*)(void*), void*>(void (*&&)(unsigned long, Thread::Settings const&, void (*)(void*), void*), unsigned long&&, Thread::Settings&&, void (*&&)(void*), void*&&) /usr/include/c++/14/bits/invoke.h:96
    #13 0xcc78d56 in void std::thread::_Invoker<std::tuple<void (*)(unsigned long, Thread::Settings const&, void (*)(void*), void*), unsigned long, Thread::Settings, void (*)(void*), void*> >::_M_invoke<0ul, 1ul, 2ul, 3ul, 4ul>(std::_Index_tuple<0ul, 1ul, 2ul, 3ul, 4ul>) /usr/include/c++/14/bits/std_thread.h:292
    #14 0xcc78cbb in std::thread::_Invoker<std::tuple<void (*)(unsigned long, Thread::Settings const&, void (*)(void*), void*), unsigned long, Thread::Settings, void (*)(void*), void*> >::operator()() /usr/include/c++/14/bits/std_thread.h:299
    #15 0xcc78c9f in std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(unsigned long, Thread::Settings const&, void (*)(void*), void*), unsigned long, Thread::Settings, void (*)(void*), void*> > >::_M_run() /usr/include/c++/14/bits/std_thread.h:244
    #16 0xe6bfab3 in execute_native_thread_routine (/home/akien/Godot/godot/bin/godot.linuxbsd.editor.dev.x86_64.san+0xe6bfab3) (BuildId: 5493d949a28c2f8952cb1bc742f363f7b6d5b8b5)
    #17 0x7fa4e0c5db45 in asan_thread_start(void*) (/lib64/libasan.so.8+0x5db45) (BuildId: 9398d675390359c74744b0e7714408910d853874)
    #18 0x7fa4e09c61b6 in start_thread (/lib64/libc.so.6+0x961b6) (BuildId: b098f1c75a76548bb230d8f551eae07a2aeccf06)
    #19 0x7fa4e0a4839b in clone3 (/lib64/libc.so.6+0x11839b) (BuildId: b098f1c75a76548bb230d8f551eae07a2aeccf06)

0x512000bb7318 is located 88 bytes inside of 272-byte region [0x512000bb72c0,0x512000bb73d0)
freed by thread T0 here:
    #0 0x7fa4e0cf57b8 in realloc.part.0 (/lib64/libasan.so.8+0xf57b8) (BuildId: 9398d675390359c74744b0e7714408910d853874)
    #1 0xcc6b379 in Memory::realloc_static(void*, unsigned long, bool) core/os/memory.cpp:129
    #2 0x2c36b4f in LocalVector<unsigned char, unsigned int, false, false>::resize(unsigned int) core/templates/local_vector.h:161
    #3 0xbaddddf in CommandQueueMT::Command1<RendererMaterialStorage, void (RendererMaterialStorage::*)(RID), RID>* CommandQueueMT::allocate<CommandQueueMT::Command1<RendererMaterialStorage, void (RendererMaterialStorage::*)(RID), RID> >() (/home/akien/Godot/godot/bin/godot.linuxbsd.editor.dev.x86_64.san+0xbaddddf) (BuildId: 5493d949a28c2f8952cb1bc742f363f7b6d5b8b5)
    #4 0xbaa7901 in void CommandQueueMT::push<RendererMaterialStorage, void (RendererMaterialStorage::*)(RID), RID>(RendererMaterialStorage*, void (RendererMaterialStorage::*)(RID), RID) core/templates/command_queue_mt.h:393
    #5 0xba6102b in RenderingServerDefault::shader_create() servers/rendering/rendering_server_default.h:229
    #6 0xa494c10 in Shader::Shader() scene/resources/shader.cpp:261
    #7 0x6776986 in void Ref<Shader>::instantiate<>() core/object/ref_counted.h:217
    #8 0x892c264 in ColorPicker::init_shaders() scene/gui/color_picker.cpp:207
    #9 0x8364686 in register_scene_types() scene/register_scene_types.cpp:1230
    #10 0x2d6c207 in Main::setup2() main/main.cpp:3055
    #11 0x2d6323d in Main::setup(char const*, int, char**, bool) main/main.cpp:2432
    #12 0x2ba0d3c in main platform/linuxbsd/godot_linuxbsd.cpp:74
    #13 0x7fa4e095a087 in __libc_start_call_main (/lib64/libc.so.6+0x2a087) (BuildId: b098f1c75a76548bb230d8f551eae07a2aeccf06)
    #14 0x7fa4e095a14a in __libc_start_main_alias_2 (/lib64/libc.so.6+0x2a14a) (BuildId: b098f1c75a76548bb230d8f551eae07a2aeccf06)
    #15 0x2ba09b4 in _start (/home/akien/Godot/godot/bin/godot.linuxbsd.editor.dev.x86_64.san+0x2ba09b4) (BuildId: 5493d949a28c2f8952cb1bc742f363f7b6d5b8b5)

previously allocated by thread T0 here:
    #0 0x7fa4e0cf57b8 in realloc.part.0 (/lib64/libasan.so.8+0xf57b8) (BuildId: 9398d675390359c74744b0e7714408910d853874)
    #1 0xcc6b379 in Memory::realloc_static(void*, unsigned long, bool) core/os/memory.cpp:129
    #2 0x2c36b4f in LocalVector<unsigned char, unsigned int, false, false>::resize(unsigned int) core/templates/local_vector.h:161
    #3 0xbaddddf in CommandQueueMT::Command1<RendererMaterialStorage, void (RendererMaterialStorage::*)(RID), RID>* CommandQueueMT::allocate<CommandQueueMT::Command1<RendererMaterialStorage, void (RendererMaterialStorage::*)(RID), RID> >() (/home/akien/Godot/godot/bin/godot.linuxbsd.editor.dev.x86_64.san+0xbaddddf) (BuildId: 5493d949a28c2f8952cb1bc742f363f7b6d5b8b5)
    #4 0xbaa7901 in void CommandQueueMT::push<RendererMaterialStorage, void (RendererMaterialStorage::*)(RID), RID>(RendererMaterialStorage*, void (RendererMaterialStorage::*)(RID), RID) core/templates/command_queue_mt.h:393
    #5 0xba6102b in RenderingServerDefault::shader_create() servers/rendering/rendering_server_default.h:229
    #6 0xa494c10 in Shader::Shader() scene/resources/shader.cpp:261
    #7 0x6776986 in void Ref<Shader>::instantiate<>() core/object/ref_counted.h:217
    #8 0x892c1ff in ColorPicker::init_shaders() scene/gui/color_picker.cpp:182
    #9 0x8364686 in register_scene_types() scene/register_scene_types.cpp:1230
    #10 0x2d6c207 in Main::setup2() main/main.cpp:3055
    #11 0x2d6323d in Main::setup(char const*, int, char**, bool) main/main.cpp:2432
    #12 0x2ba0d3c in main platform/linuxbsd/godot_linuxbsd.cpp:74
    #13 0x7fa4e095a087 in __libc_start_call_main (/lib64/libc.so.6+0x2a087) (BuildId: b098f1c75a76548bb230d8f551eae07a2aeccf06)
    #14 0x7fa4e095a14a in __libc_start_main_alias_2 (/lib64/libc.so.6+0x2a14a) (BuildId: b098f1c75a76548bb230d8f551eae07a2aeccf06)
    #15 0x2ba09b4 in _start (/home/akien/Godot/godot/bin/godot.linuxbsd.editor.dev.x86_64.san+0x2ba09b4) (BuildId: 5493d949a28c2f8952cb1bc742f363f7b6d5b8b5)

Thread T2 created by T0 here:
    #0 0x7fa4e0cee7d1 in pthread_create (/lib64/libasan.so.8+0xee7d1) (BuildId: 9398d675390359c74744b0e7714408910d853874)
    #1 0xe6bfb88 in std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) (/home/akien/Godot/godot/bin/godot.linuxbsd.editor.dev.x86_64.san+0xe6bfb88) (BuildId: 5493d949a28c2f8952cb1bc742f363f7b6d5b8b5)
    #2 0xcc77e54 in Thread::start(void (*)(void*), void*, Thread::Settings const&) core/os/thread.cpp:75
    #3 0xda3d364 in WorkerThreadPool::init(int, float) core/object/worker_thread_pool.cpp:655
    #4 0x2d4d251 in Main::setup(char const*, int, char**, bool) main/main.cpp:1777
    #5 0x2ba0d3c in main platform/linuxbsd/godot_linuxbsd.cpp:74
    #6 0x7fa4e095a087 in __libc_start_call_main (/lib64/libc.so.6+0x2a087) (BuildId: b098f1c75a76548bb230d8f551eae07a2aeccf06)
    #7 0x7fa4e095a14a in __libc_start_main_alias_2 (/lib64/libc.so.6+0x2a14a) (BuildId: b098f1c75a76548bb230d8f551eae07a2aeccf06)
    #8 0x2ba09b4 in _start (/home/akien/Godot/godot/bin/godot.linuxbsd.editor.dev.x86_64.san+0x2ba09b4) (BuildId: 5493d949a28c2f8952cb1bc742f363f7b6d5b8b5)

SUMMARY: AddressSanitizer: heap-use-after-free core/templates/command_queue_mt.h:366 in CommandQueueMT::_flush()
Shadow bytes around the buggy address:
  0x512000bb7080: fd fd fd fd fd fd fd fd fd fd fa fa fa fa fa fa
  0x512000bb7100: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
  0x512000bb7180: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x512000bb7200: fd fd fd fd fd fd fd fd fd fd fa fa fa fa fa fa
  0x512000bb7280: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
=>0x512000bb7300: fd fd fd[fd]fd fd fd fd fd fd fd fd fd fd fd fd
  0x512000bb7380: fd fd fd fd fd fd fd fd fd fd fa fa fa fa fa fa
  0x512000bb7400: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
  0x512000bb7480: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x512000bb7500: fd fd fd fd fd fd fd fd fd fd fa fa fa fa fa fa
  0x512000bb7580: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==244351==ABORTING

I then tested with #90913, which seems to fix the use-after-free.

Now I only get this leak reported in the Vulkan driver:

=================================================================
==246111==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 128 byte(s) in 1 object(s) allocated from:
    #0 0x7fd3110f57b8 in realloc.part.0 (/lib64/libasan.so.8+0xf57b8) (BuildId: 9398d675390359c74744b0e7714408910d853874)
    #1 0x7fd2d8a38363  (<unknown module>)
    #2 0x7fd2d8a3895e  (<unknown module>)
    #3 0x7fd310eae51a in __pthread_once_slow.isra.0 (/lib64/libc.so.6+0x9b51a) (BuildId: b098f1c75a76548bb230d8f551eae07a2aeccf06)
    #4 0x7fd310eae588 in pthread_once@GLIBC_2.2.5 (/lib64/libc.so.6+0x9b588) (BuildId: b098f1c75a76548bb230d8f551eae07a2aeccf06)
    #5 0x7fd2d8a36c8f  (<unknown module>)
    #6 0x7fd2d8a5d69b  (<unknown module>)
    #7 0x7fd31105db45 in asan_thread_start(void*) (/lib64/libasan.so.8+0x5db45) (BuildId: 9398d675390359c74744b0e7714408910d853874)

Direct leak of 128 byte(s) in 1 object(s) allocated from:
    #0 0x7fd3110f57b8 in realloc.part.0 (/lib64/libasan.so.8+0xf57b8) (BuildId: 9398d675390359c74744b0e7714408910d853874)
    #1 0x7fd2e0eef2e3  (<unknown module>)
    #2 0x7fd2e0eef8de  (<unknown module>)
    #3 0x7fd310eae51a in __pthread_once_slow.isra.0 (/lib64/libc.so.6+0x9b51a) (BuildId: b098f1c75a76548bb230d8f551eae07a2aeccf06)
    #4 0x7fd310eae588 in pthread_once@GLIBC_2.2.5 (/lib64/libc.so.6+0x9b588) (BuildId: b098f1c75a76548bb230d8f551eae07a2aeccf06)
    #5 0x7fd2e1060e26  (<unknown module>)
    #6 0x7fd2e0e37638  (<unknown module>)
    #7 0x7fd2e0eaba4c  (<unknown module>)
    #8 0x7fd2e0eab9b4  (<unknown module>)
    #9 0x7fd2e0e8e670  (<unknown module>)
    #10 0x7fd2e0e8fc17  (<unknown module>)
    #11 0x7fd2e0e53c40  (<unknown module>)
    #12 0x7fd2e0e54881  (<unknown module>)
    #13 0x7fd2fcfae22d in setup_loader_term_phys_devs (/lib64/libvulkan.so.1+0x2722d) (BuildId: b3e925786cbf5b599b909ff527b5b48ee708f523)
    #14 0x7fd2fcfae98c in terminator_EnumeratePhysicalDevices (/lib64/libvulkan.so.1+0x2798c) (BuildId: b3e925786cbf5b599b909ff527b5b48ee708f523)
    #15 0x7fd2fce28ad2  (/home/akien/Godot/godot/bin/godot.linuxbsd.editor.dev.x86_64.san+0x2da28ad2)
    #16 0x7fd2fcfb47f0 in vkEnumeratePhysicalDevices (/lib64/libvulkan.so.1+0x2d7f0) (BuildId: b3e925786cbf5b599b909ff527b5b48ee708f523)
    #17 0x5b71baf in RenderingContextDriverVulkan::_initialize_devices() drivers/vulkan/rendering_context_driver_vulkan.cpp:485
    #18 0x5b7267f in RenderingContextDriverVulkan::initialize() drivers/vulkan/rendering_context_driver_vulkan.cpp:562
    #19 0x2c26293 in DisplayServerX11::DisplayServerX11(String const&, DisplayServer::WindowMode, DisplayServer::VSyncMode, unsigned int, Vector2i const*, Vector2i const&, int, Error&) platform/linuxbsd/x11/display_server_x11.cpp:6062
    #20 0x2c1bb50 in DisplayServerX11::create_func(String const&, DisplayServer::WindowMode, DisplayServer::VSyncMode, unsigned int, Vector2i const*, Vector2i const&, int, Error&) platform/linuxbsd/x11/display_server_x11.cpp:5324
    #21 0xadc5ac9 in DisplayServer::create(int, String const&, DisplayServer::WindowMode, DisplayServer::VSyncMode, unsigned int, Vector2i const*, Vector2i const&, int, Error&) servers/display_server.cpp:1188
    #22 0x2d6883f in Main::setup2() main/main.cpp:2691
    #23 0x2d652d7 in Main::setup(char const*, int, char**, bool) main/main.cpp:2432
    #24 0x2ba2d3c in main platform/linuxbsd/godot_linuxbsd.cpp:74
    #25 0x7fd310e3d087 in __libc_start_call_main (/lib64/libc.so.6+0x2a087) (BuildId: b098f1c75a76548bb230d8f551eae07a2aeccf06)
    #26 0x7fd310e3d14a in __libc_start_main_alias_2 (/lib64/libc.so.6+0x2a14a) (BuildId: b098f1c75a76548bb230d8f551eae07a2aeccf06)
    #27 0x2ba29b4 in _start (/home/akien/Godot/godot/bin/godot.linuxbsd.editor.dev.x86_64.san+0x2ba29b4) (BuildId: 5992b98d96a2241fd44f640d4b7fe7f84615f623)

SUMMARY: AddressSanitizer: 256 byte(s) leaked in 2 allocation(s).

And none reported with --headless.

So I think we can consider that #90913 fixes this sufficiently. We can maybe open a new ticket to track the Vulkan driver leak, if it's confirmed not to be a false positive.

qarmin commented 4 months ago

Can't reproduce leak, because I have exactly same crash in CommandQueueMT