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

Lock-order-inversion detected by ThreadSanitizer in TextServerAdvanced #87990

Open
Rubonnek opened this issue Feb 5, 2024 · 5 comments · May be fixed by #88241
Open

Lock-order-inversion detected by ThreadSanitizer in TextServerAdvanced #87990

Rubonnek opened this issue Feb 5, 2024 · 5 comments · May be fixed by #88241
Assignees

Comments

@Rubonnek
Copy link
Member

Rubonnek commented Feb 5, 2024

Tested versions

63d6bda - reproducible

System information

Godot v4.3.dev (63d6bda) - Arch Linux #1 SMP PREEMPT_DYNAMIC Fri, 02 Feb 2024 17:03:55 +0000 - Tty - Vulkan (Forward+) - dedicated AMD Radeon RX 6900 XT (RADV NAVI21) () - AMD Ryzen 9 5950X 16-Core Processor (32 Threads)

Issue description

Opening the Editor against an empty project with ThreadSanitizer enabled will generate a lock-order-inversion (potential deadlock) warning. The Editor deadlocks are quite rare in my computer, but they tend to happen when I close the Editor -- I suppose the ThreadSanitizer warning is related to those deadlocks I've had in the past.

Steps to reproduce

  1. Compile Godot with ThreadSanitizer enabled -- the following is the command I used:
scons -Q -s platform=linuxbsd dev_mode=yes dev_build=yes udev=yes target=editor debug_symbols=yes precision=single bits=64 optimize=debug compiledb=yes use_llvm=yes linker=lld tests=yes use_asan=no use_tsan=yes werror=no -j$(nproc)

If you are on Arch Linux, it seems that linking to libatomic.a is unnecessary -- you may need to apply the following patch and try to compile again if it previously failed:

diff --git a/platform/linuxbsd/detect.py b/platform/linuxbsd/detect.py
index 7946ef6228..14471c2393 100644
--- a/platform/linuxbsd/detect.py
+++ b/platform/linuxbsd/detect.py
@@ -520,8 +520,6 @@ def configure(env: "Environment"):
     # Link those statically for portability
     if env["use_static_cpp"]:
         env.Append(LINKFLAGS=["-static-libgcc", "-static-libstdc++"])
-        if env["use_llvm"] and platform.system() != "FreeBSD":
-            env["LINKCOM"] = env["LINKCOM"] + " -l:libatomic.a"
     else:
         if env["use_llvm"] and platform.system() != "FreeBSD":
             env.Append(LIBS=["atomic"])
  1. Decompress the MRP below and open a terminal at the MRP project path and run:
TSAN_OPTIONS=second_deadlock_stack=1 /opt/godot/bin/godot.linuxbsd.editor.dev.x86_64.llvm.san -e

If the FATAL: ThreadSanitizer: unexpected memory mapping error appears, you may need to temporarily lower the ASLR entropy:

sudo sysctl vm.mmap_rnd_bits=28
# reverse it with: sudo sysctl vm.mmap_rnd_bits=32

OR disable ASLR entirely temporarily :

sudo sysctl kernel.randomize_va_space=0
# reverse it with:sudo sysctl kernel.randomize_va_space=2
  1. The following ThreadSanitizer warning should appear:
==================
WARNING: ThreadSanitizer: lock-order-inversion (potential deadlock) (pid=41490)
  Cycle in lock order graph: M0 (0x7b500000d410) => M1 (0x7b8800022590) => M0

  Mutex M1 acquired here while holding mutex M0 in main thread:
    #0 pthread_mutex_lock <null> (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x3b0dd71) (BuildId: 77398a27c54674f8)
    #1 __gthread_mutex_lock(pthread_mutex_t*) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/x86_64-pc-linux-gnu/bits/gthr-default.h:749:12 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53c338d) (BuildId: 77398a27c54674f8)
    #2 __gthread_recursive_mutex_lock(pthread_mutex_t*) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/x86_64-pc-linux-gnu/bits/gthr-default.h:811:10 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53c338d)
    #3 std::recursive_mutex::lock() /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/mutex:120:17 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53c338d)
    #4 std::unique_lock<std::recursive_mutex>::lock() /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/unique_lock.h:141:17 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53c338d)
    #5 std::unique_lock<std::recursive_mutex>::unique_lock(std::recursive_mutex&) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/unique_lock.h:71:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53c338d)
    #6 MutexLock<MutexImpl<std::recursive_mutex>>::MutexLock(MutexImpl<std::recursive_mutex> const&) /opt/godot/./core/os/mutex.h:81:4 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53c338d)
    #7 TextServerAdvanced::_shaped_text_shape(RID const&) /opt/godot/modules/text_server_adv/text_server_adv.cpp:6084:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53c338d)
    #8 TextServerAdvanced::_shaped_text_update_breaks(RID const&) /opt/godot/modules/text_server_adv/text_server_adv.cpp:5326:3 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53bc60b) (BuildId: 77398a27c54674f8)
    #9 TextServerAdvanced::shaped_text_update_breaks(RID const&) /opt/godot/modules/text_server_adv/text_server_adv.h:941:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53e0d5a) (BuildId: 77398a27c54674f8)
    #10 TextServer::shaped_text_get_line_breaks(RID const&, double, long, BitField<TextServer::LineBreakFlag>) const /opt/godot/servers/text_server.cpp:868:34 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x8b27bb1) (BuildId: 77398a27c54674f8)
    #11 TextServerExtension::shaped_text_get_line_breaks(RID const&, double, long, BitField<TextServer::LineBreakFlag>) const /opt/godot/servers/text/text_server_extension.cpp:1236:21 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x93ba135) (BuildId: 77398a27c54674f8)
    #12 TextParagraph::_shape_lines() /opt/godot/scene/resources/text_paragraph.cpp:195:38 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x844dc4f) (BuildId: 77398a27c54674f8)
    #13 TextParagraph::get_size() const /opt/godot/scene/resources/text_paragraph.cpp:552:37 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x844698e) (BuildId: 77398a27c54674f8)
    #14 Button::get_minimum_size_for_text_and_icon(String const&, Ref<Texture2D>) const /opt/godot/scene/gui/button.cpp:417:29 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x721a98b) (BuildId: 77398a27c54674f8)
    #15 Button::get_minimum_size() const /opt/godot/scene/gui/button.cpp:43:9 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x721a5db) (BuildId: 77398a27c54674f8)
    #16 Control::_update_minimum_size_cache() /opt/godot/scene/gui/control.cpp:1652:18 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x72ec55b) (BuildId: 77398a27c54674f8)
    #17 Control::get_combined_minimum_size() const /opt/godot/scene/gui/control.cpp:1663:32 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x72ec55b)
    #18 BoxContainer::get_minimum_size() const /opt/godot/scene/gui/box_container.cpp:267:20 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x7215ae6) (BuildId: 77398a27c54674f8)
    #19 Control::_update_minimum_size_cache() /opt/godot/scene/gui/control.cpp:1652:18 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x72ec55b) (BuildId: 77398a27c54674f8)
    #20 Control::get_combined_minimum_size() const /opt/godot/scene/gui/control.cpp:1663:32 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x72ec55b)
    #21 BoxContainer::get_minimum_size() const /opt/godot/scene/gui/box_container.cpp:267:20 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x7215ae6) (BuildId: 77398a27c54674f8)
    #22 Control::_update_minimum_size_cache() /opt/godot/scene/gui/control.cpp:1652:18 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x72ec55b) (BuildId: 77398a27c54674f8)
    #23 Control::get_combined_minimum_size() const /opt/godot/scene/gui/control.cpp:1663:32 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x72ec55b)
    #24 PopupPanel::_get_contents_minimum_size() const /opt/godot/scene/gui/popup.cpp:226:18 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x74bf354) (BuildId: 77398a27c54674f8)
    #25 Window::get_contents_minimum_size() const /opt/godot/scene/main/window.cpp:1895:9 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x71b1652) (BuildId: 77398a27c54674f8)
    #26 Window::get_clamped_minimum_size() const /opt/godot/scene/main/window.cpp:1904:22 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x71a1365) (BuildId: 77398a27c54674f8)
    #27 Window::_update_window_size() /opt/godot/scene/main/window.cpp:1011:22 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x71a1570) (BuildId: 77398a27c54674f8)
    #28 Window::set_size(Vector2i const&) /opt/godot/scene/main/window.cpp:383:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x71a305d) (BuildId: 77398a27c54674f8)
    #29 Window::reset_size() /opt/godot/scene/main/window.cpp:393:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x71a3207) (BuildId: 77398a27c54674f8)
    #30 EditorDockManager::EditorDockManager() /opt/godot/editor/editor_dock_manager.cpp:865:21 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x5a976c0) (BuildId: 77398a27c54674f8)
    #31 EditorNode::EditorNode() /opt/godot/editor/editor_node.cpp:6597:24 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x5a4c904) (BuildId: 77398a27c54674f8)
    #32 Main::start() /opt/godot/main/main.cpp:3578:18 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x3ccea06) (BuildId: 77398a27c54674f8)
    #33 main /opt/godot/platform/linuxbsd/godot_linuxbsd.cpp:72:6 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x3b91e19) (BuildId: 77398a27c54674f8)

  Mutex M0 previously acquired by the same thread here:
    #0 pthread_mutex_lock <null> (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x3b0dd71) (BuildId: 77398a27c54674f8)
    #1 __gthread_mutex_lock(pthread_mutex_t*) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/x86_64-pc-linux-gnu/bits/gthr-default.h:749:12 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53bc5d4) (BuildId: 77398a27c54674f8)
    #2 __gthread_recursive_mutex_lock(pthread_mutex_t*) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/x86_64-pc-linux-gnu/bits/gthr-default.h:811:10 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53bc5d4)
    #3 std::recursive_mutex::lock() /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/mutex:120:17 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53bc5d4)
    #4 std::unique_lock<std::recursive_mutex>::lock() /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/unique_lock.h:141:17 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53bc5d4)
    #5 std::unique_lock<std::recursive_mutex>::unique_lock(std::recursive_mutex&) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/unique_lock.h:71:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53bc5d4)
    #6 MutexLock<MutexImpl<std::recursive_mutex>>::MutexLock(MutexImpl<std::recursive_mutex> const&) /opt/godot/./core/os/mutex.h:81:4 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53bc5d4)
    #7 TextServerAdvanced::_shaped_text_update_breaks(RID const&) /opt/godot/modules/text_server_adv/text_server_adv.cpp:5324:12 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53bc5d4)
    #8 TextServerAdvanced::shaped_text_update_breaks(RID const&) /opt/godot/modules/text_server_adv/text_server_adv.h:941:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53e0d5a) (BuildId: 77398a27c54674f8)
    #9 TextServer::shaped_text_get_line_breaks(RID const&, double, long, BitField<TextServer::LineBreakFlag>) const /opt/godot/servers/text_server.cpp:868:34 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x8b27bb1) (BuildId: 77398a27c54674f8)
    #10 TextServerExtension::shaped_text_get_line_breaks(RID const&, double, long, BitField<TextServer::LineBreakFlag>) const /opt/godot/servers/text/text_server_extension.cpp:1236:21 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x93ba135) (BuildId: 77398a27c54674f8)
    #11 TextParagraph::_shape_lines() /opt/godot/scene/resources/text_paragraph.cpp:195:38 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x844dc4f) (BuildId: 77398a27c54674f8)
    #12 TextParagraph::get_size() const /opt/godot/scene/resources/text_paragraph.cpp:552:37 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x844698e) (BuildId: 77398a27c54674f8)
    #13 Button::get_minimum_size_for_text_and_icon(String const&, Ref<Texture2D>) const /opt/godot/scene/gui/button.cpp:417:29 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x721a98b) (BuildId: 77398a27c54674f8)
    #14 Button::get_minimum_size() const /opt/godot/scene/gui/button.cpp:43:9 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x721a5db) (BuildId: 77398a27c54674f8)
    #15 Control::_update_minimum_size_cache() /opt/godot/scene/gui/control.cpp:1652:18 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x72ec55b) (BuildId: 77398a27c54674f8)
    #16 Control::get_combined_minimum_size() const /opt/godot/scene/gui/control.cpp:1663:32 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x72ec55b)
    #17 BoxContainer::get_minimum_size() const /opt/godot/scene/gui/box_container.cpp:267:20 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x7215ae6) (BuildId: 77398a27c54674f8)
    #18 Control::_update_minimum_size_cache() /opt/godot/scene/gui/control.cpp:1652:18 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x72ec55b) (BuildId: 77398a27c54674f8)
    #19 Control::get_combined_minimum_size() const /opt/godot/scene/gui/control.cpp:1663:32 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x72ec55b)
    #20 BoxContainer::get_minimum_size() const /opt/godot/scene/gui/box_container.cpp:267:20 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x7215ae6) (BuildId: 77398a27c54674f8)
    #21 Control::_update_minimum_size_cache() /opt/godot/scene/gui/control.cpp:1652:18 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x72ec55b) (BuildId: 77398a27c54674f8)
    #22 Control::get_combined_minimum_size() const /opt/godot/scene/gui/control.cpp:1663:32 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x72ec55b)
    #23 PopupPanel::_get_contents_minimum_size() const /opt/godot/scene/gui/popup.cpp:226:18 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x74bf354) (BuildId: 77398a27c54674f8)
    #24 Window::get_contents_minimum_size() const /opt/godot/scene/main/window.cpp:1895:9 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x71b1652) (BuildId: 77398a27c54674f8)
    #25 Window::get_clamped_minimum_size() const /opt/godot/scene/main/window.cpp:1904:22 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x71a1365) (BuildId: 77398a27c54674f8)
    #26 Window::_update_window_size() /opt/godot/scene/main/window.cpp:1011:22 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x71a1570) (BuildId: 77398a27c54674f8)
    #27 Window::set_size(Vector2i const&) /opt/godot/scene/main/window.cpp:383:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x71a305d) (BuildId: 77398a27c54674f8)
    #28 Window::reset_size() /opt/godot/scene/main/window.cpp:393:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x71a3207) (BuildId: 77398a27c54674f8)
    #29 EditorDockManager::EditorDockManager() /opt/godot/editor/editor_dock_manager.cpp:865:21 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x5a976c0) (BuildId: 77398a27c54674f8)
    #30 EditorNode::EditorNode() /opt/godot/editor/editor_node.cpp:6597:24 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x5a4c904) (BuildId: 77398a27c54674f8)
    #31 Main::start() /opt/godot/main/main.cpp:3578:18 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x3ccea06) (BuildId: 77398a27c54674f8)
    #32 main /opt/godot/platform/linuxbsd/godot_linuxbsd.cpp:72:6 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x3b91e19) (BuildId: 77398a27c54674f8)

  Mutex M0 acquired here while holding mutex M1 in main thread:
    #0 pthread_mutex_lock <null> (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x3b0dd71) (BuildId: 77398a27c54674f8)
    #1 __gthread_mutex_lock(pthread_mutex_t*) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/x86_64-pc-linux-gnu/bits/gthr-default.h:749:12 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53b5711) (BuildId: 77398a27c54674f8)
    #2 __gthread_recursive_mutex_lock(pthread_mutex_t*) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/x86_64-pc-linux-gnu/bits/gthr-default.h:811:10 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53b5711)
    #3 std::recursive_mutex::lock() /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/mutex:120:17 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53b5711)
    #4 std::unique_lock<std::recursive_mutex>::lock() /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/unique_lock.h:141:17 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53b5711)
    #5 std::unique_lock<std::recursive_mutex>::unique_lock(std::recursive_mutex&) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/unique_lock.h:71:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53b5711)
    #6 MutexLock<MutexImpl<std::recursive_mutex>>::MutexLock(MutexImpl<std::recursive_mutex> const&) /opt/godot/./core/os/mutex.h:81:4 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53b5711)
    #7 TextServerAdvanced::_shaped_text_substr(RID const&, long, long) const /opt/godot/modules/text_server_adv/text_server_adv.cpp:4459:12 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53b5711)
    #8 TextServerAdvanced::shaped_text_substr(RID const&, long, long) const /opt/godot/modules/text_server_adv/text_server_adv.h:934:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53e0bcb) (BuildId: 77398a27c54674f8)
    #9 TextParagraph::_shape_lines() /opt/godot/scene/resources/text_paragraph.cpp:197:19 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x844ddff) (BuildId: 77398a27c54674f8)
    #10 TextParagraph::get_size() const /opt/godot/scene/resources/text_paragraph.cpp:552:37 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x844698e) (BuildId: 77398a27c54674f8)
    #11 Button::get_minimum_size_for_text_and_icon(String const&, Ref<Texture2D>) const /opt/godot/scene/gui/button.cpp:417:29 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x721a98b) (BuildId: 77398a27c54674f8)
    #12 Button::get_minimum_size() const /opt/godot/scene/gui/button.cpp:43:9 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x721a5db) (BuildId: 77398a27c54674f8)
    #13 Control::_update_minimum_size_cache() /opt/godot/scene/gui/control.cpp:1652:18 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x72ec55b) (BuildId: 77398a27c54674f8)
    #14 Control::get_combined_minimum_size() const /opt/godot/scene/gui/control.cpp:1663:32 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x72ec55b)
    #15 BoxContainer::get_minimum_size() const /opt/godot/scene/gui/box_container.cpp:267:20 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x7215ae6) (BuildId: 77398a27c54674f8)
    #16 Control::_update_minimum_size_cache() /opt/godot/scene/gui/control.cpp:1652:18 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x72ec55b) (BuildId: 77398a27c54674f8)
    #17 Control::get_combined_minimum_size() const /opt/godot/scene/gui/control.cpp:1663:32 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x72ec55b)
    #18 BoxContainer::get_minimum_size() const /opt/godot/scene/gui/box_container.cpp:267:20 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x7215ae6) (BuildId: 77398a27c54674f8)
    #19 Control::_update_minimum_size_cache() /opt/godot/scene/gui/control.cpp:1652:18 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x72ec55b) (BuildId: 77398a27c54674f8)
    #20 Control::get_combined_minimum_size() const /opt/godot/scene/gui/control.cpp:1663:32 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x72ec55b)
    #21 PopupPanel::_get_contents_minimum_size() const /opt/godot/scene/gui/popup.cpp:226:18 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x74bf354) (BuildId: 77398a27c54674f8)
    #22 Window::get_contents_minimum_size() const /opt/godot/scene/main/window.cpp:1895:9 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x71b1652) (BuildId: 77398a27c54674f8)
    #23 Window::get_clamped_minimum_size() const /opt/godot/scene/main/window.cpp:1904:22 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x71a1365) (BuildId: 77398a27c54674f8)
    #24 Window::_update_window_size() /opt/godot/scene/main/window.cpp:1011:22 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x71a1570) (BuildId: 77398a27c54674f8)
    #25 Window::set_size(Vector2i const&) /opt/godot/scene/main/window.cpp:383:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x71a305d) (BuildId: 77398a27c54674f8)
    #26 Window::reset_size() /opt/godot/scene/main/window.cpp:393:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x71a3207) (BuildId: 77398a27c54674f8)
    #27 EditorDockManager::EditorDockManager() /opt/godot/editor/editor_dock_manager.cpp:865:21 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x5a976c0) (BuildId: 77398a27c54674f8)
    #28 EditorNode::EditorNode() /opt/godot/editor/editor_node.cpp:6597:24 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x5a4c904) (BuildId: 77398a27c54674f8)
    #29 Main::start() /opt/godot/main/main.cpp:3578:18 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x3ccea06) (BuildId: 77398a27c54674f8)
    #30 main /opt/godot/platform/linuxbsd/godot_linuxbsd.cpp:72:6 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x3b91e19) (BuildId: 77398a27c54674f8)

  Mutex M1 previously acquired by the same thread here:
    #0 pthread_mutex_lock <null> (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x3b0dd71) (BuildId: 77398a27c54674f8)
    #1 __gthread_mutex_lock(pthread_mutex_t*) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/x86_64-pc-linux-gnu/bits/gthr-default.h:749:12 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53b5626) (BuildId: 77398a27c54674f8)
    #2 __gthread_recursive_mutex_lock(pthread_mutex_t*) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/x86_64-pc-linux-gnu/bits/gthr-default.h:811:10 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53b5626)
    #3 std::recursive_mutex::lock() /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/mutex:120:17 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53b5626)
    #4 std::unique_lock<std::recursive_mutex>::lock() /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/unique_lock.h:141:17 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53b5626)
    #5 std::unique_lock<std::recursive_mutex>::unique_lock(std::recursive_mutex&) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/unique_lock.h:71:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53b5626)
    #6 MutexLock<MutexImpl<std::recursive_mutex>>::MutexLock(MutexImpl<std::recursive_mutex> const&) /opt/godot/./core/os/mutex.h:81:4 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53b5626)
    #7 TextServerAdvanced::_shaped_text_substr(RID const&, long, long) const /opt/godot/modules/text_server_adv/text_server_adv.cpp:4455:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53b5626)
    #8 TextServerAdvanced::shaped_text_substr(RID const&, long, long) const /opt/godot/modules/text_server_adv/text_server_adv.h:934:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53e0bcb) (BuildId: 77398a27c54674f8)
    #9 TextParagraph::_shape_lines() /opt/godot/scene/resources/text_paragraph.cpp:197:19 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x844ddff) (BuildId: 77398a27c54674f8)
    #10 TextParagraph::get_size() const /opt/godot/scene/resources/text_paragraph.cpp:552:37 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x844698e) (BuildId: 77398a27c54674f8)
    #11 Button::get_minimum_size_for_text_and_icon(String const&, Ref<Texture2D>) const /opt/godot/scene/gui/button.cpp:417:29 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x721a98b) (BuildId: 77398a27c54674f8)
    #12 Button::get_minimum_size() const /opt/godot/scene/gui/button.cpp:43:9 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x721a5db) (BuildId: 77398a27c54674f8)
    #13 Control::_update_minimum_size_cache() /opt/godot/scene/gui/control.cpp:1652:18 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x72ec55b) (BuildId: 77398a27c54674f8)
    #14 Control::get_combined_minimum_size() const /opt/godot/scene/gui/control.cpp:1663:32 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x72ec55b)
    #15 BoxContainer::get_minimum_size() const /opt/godot/scene/gui/box_container.cpp:267:20 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x7215ae6) (BuildId: 77398a27c54674f8)
    #16 Control::_update_minimum_size_cache() /opt/godot/scene/gui/control.cpp:1652:18 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x72ec55b) (BuildId: 77398a27c54674f8)
    #17 Control::get_combined_minimum_size() const /opt/godot/scene/gui/control.cpp:1663:32 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x72ec55b)
    #18 BoxContainer::get_minimum_size() const /opt/godot/scene/gui/box_container.cpp:267:20 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x7215ae6) (BuildId: 77398a27c54674f8)
    #19 Control::_update_minimum_size_cache() /opt/godot/scene/gui/control.cpp:1652:18 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x72ec55b) (BuildId: 77398a27c54674f8)
    #20 Control::get_combined_minimum_size() const /opt/godot/scene/gui/control.cpp:1663:32 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x72ec55b)
    #21 PopupPanel::_get_contents_minimum_size() const /opt/godot/scene/gui/popup.cpp:226:18 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x74bf354) (BuildId: 77398a27c54674f8)
    #22 Window::get_contents_minimum_size() const /opt/godot/scene/main/window.cpp:1895:9 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x71b1652) (BuildId: 77398a27c54674f8)
    #23 Window::get_clamped_minimum_size() const /opt/godot/scene/main/window.cpp:1904:22 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x71a1365) (BuildId: 77398a27c54674f8)
    #24 Window::_update_window_size() /opt/godot/scene/main/window.cpp:1011:22 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x71a1570) (BuildId: 77398a27c54674f8)
    #25 Window::set_size(Vector2i const&) /opt/godot/scene/main/window.cpp:383:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x71a305d) (BuildId: 77398a27c54674f8)
    #26 Window::reset_size() /opt/godot/scene/main/window.cpp:393:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x71a3207) (BuildId: 77398a27c54674f8)
    #27 EditorDockManager::EditorDockManager() /opt/godot/editor/editor_dock_manager.cpp:865:21 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x5a976c0) (BuildId: 77398a27c54674f8)
    #28 EditorNode::EditorNode() /opt/godot/editor/editor_node.cpp:6597:24 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x5a4c904) (BuildId: 77398a27c54674f8)
    #29 Main::start() /opt/godot/main/main.cpp:3578:18 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x3ccea06) (BuildId: 77398a27c54674f8)
    #30 main /opt/godot/platform/linuxbsd/godot_linuxbsd.cpp:72:6 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x3b91e19) (BuildId: 77398a27c54674f8)

SUMMARY: ThreadSanitizer: lock-order-inversion (potential deadlock) (/opt/godot/bin/godot.linuxbsd.editor.dev.x86_64.llvm.san+0x3b0dd71) (BuildId: 77398a27c54674f8) in pthread_mutex_lock
==================

Minimal reproduction project (MRP)

EmptyProject.zip

@capnm

This comment was marked as off-topic.

@Rubonnek
Copy link
Member Author

Rubonnek commented Feb 7, 2024

Related Issues: #76585, #72646

@Rubonnek
Copy link
Member Author

Rubonnek commented Feb 7, 2024

I've stumbled upon a related deadlock I can hit almost constantly with a ThreadSanitizer build (deadlock_mrp.zip) by pressing Space or Enter a few times -- the deadlock happens in my case when the LineEdit is added to the scene.

Here's the relevant ThreadSanitizer log:

Click to show log
==================
WARNING: ThreadSanitizer: lock-order-inversion (potential deadlock) (pid=134665)
  Cycle in lock order graph: M0 (0x7b50000f0410) => M1 (0x7b8800022778) => M0

  Mutex M1 acquired here while holding mutex M0 in main thread:
    #0 pthread_mutex_lock <null> (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x3b154b1) (BuildId: 0ac95bb7ee94a1ce)
    #1 __gthread_mutex_lock(pthread_mutex_t*) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/x86_64-pc-linux-gnu/bits/gthr-default.h:749:12 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53cc18c) (BuildId: 0ac95bb7ee94a1ce)
    #2 __gthread_recursive_mutex_lock(pthread_mutex_t*) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/x86_64-pc-linux-gnu/bits/gthr-default.h:811:10 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53cc18c)
    #3 std::recursive_mutex::lock() /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/mutex:120:17 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53cc18c)
    #4 std::unique_lock<std::recursive_mutex>::lock() /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/unique_lock.h:141:17 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53cc18c)
    #5 std::unique_lock<std::recursive_mutex>::unique_lock(std::recursive_mutex&) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/unique_lock.h:71:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53cc18c)
    #6 MutexLock<MutexImpl<std::recursive_mutex>>::MutexLock(MutexImpl<std::recursive_mutex> const&) /opt/godot/./core/os/mutex.h:81:4 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53cc18c)
    #7 TextServerAdvanced::_font_clear_cache(TextServerAdvanced::FontAdvanced*) /opt/godot/modules/text_server_adv/text_server_adv.cpp:1808:12 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53cc18c)
    #8 TextServerAdvanced::_font_set_data_ptr(RID const&, unsigned char const*, long) /opt/godot/modules/text_server_adv/text_server_adv.cpp:1875:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x537e892) (BuildId: 0ac95bb7ee94a1ce)
    #9 TextServerAdvanced::font_set_data_ptr(RID const&, unsigned char const*, long) /opt/godot/modules/text_server_adv/text_server_adv.h:729:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53d35ab) (BuildId: 0ac95bb7ee94a1ce)
    #10 FontFile::_ensure_rid(int, int) const /opt/godot/scene/resources/font.cpp:570:8 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x8006129) (BuildId: 0ac95bb7ee94a1ce)
    #11 FontFile::_get_rid() const /opt/godot/scene/resources/font.cpp:2330:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x7fecbf1) (BuildId: 0ac95bb7ee94a1ce)
    #12 Font::_update_rids_fb(Ref<Font> const&, int) const /opt/godot/scene/resources/font.cpp:108:18 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x7fbe71f) (BuildId: 0ac95bb7ee94a1ce)
    #13 Font::_update_rids() const /opt/godot/scene/resources/font.cpp:121:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x7fbe9c9) (BuildId: 0ac95bb7ee94a1ce)
    #14 Font::get_rids() const /opt/godot/scene/resources/font.cpp:185:3 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x7fbf3dd) (BuildId: 0ac95bb7ee94a1ce)
    #15 Label::_shape() /opt/godot/scene/gui/label.cpp:125:52 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x73dc112) (BuildId: 0ac95bb7ee94a1ce)
    #16 Label::get_minimum_size() const /opt/godot/scene/gui/label.cpp:795:30 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x73e2ceb) (BuildId: 0ac95bb7ee94a1ce)
    #17 Control::_update_minimum_size_cache() /opt/godot/scene/gui/control.cpp:1652:18 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x729dfcb) (BuildId: 0ac95bb7ee94a1ce)
    #18 Control::get_combined_minimum_size() const /opt/godot/scene/gui/control.cpp:1663:32 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x729dfcb)
    #19 PanelContainer::get_minimum_size() const /opt/godot/scene/gui/panel_container.cpp:46:22 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x746d1a4) (BuildId: 0ac95bb7ee94a1ce)
    #20 Control::_update_minimum_size_cache() /opt/godot/scene/gui/control.cpp:1652:18 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x729dfcb) (BuildId: 0ac95bb7ee94a1ce)
    #21 Control::get_combined_minimum_size() const /opt/godot/scene/gui/control.cpp:1663:32 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x729dfcb)
    #22 BoxContainer::get_minimum_size() const /opt/godot/scene/gui/box_container.cpp:267:20 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x71cdd16) (BuildId: 0ac95bb7ee94a1ce)
    #23 Control::_update_minimum_size_cache() /opt/godot/scene/gui/control.cpp:1652:18 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x729dfcb) (BuildId: 0ac95bb7ee94a1ce)
    #24 Control::get_combined_minimum_size() const /opt/godot/scene/gui/control.cpp:1663:32 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x729dfcb)
    #25 Control::_size_changed() /opt/godot/scene/gui/control.cpp:1681:23 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x728be35) (BuildId: 0ac95bb7ee94a1ce)
    #26 Control::_notification(int) /opt/godot/scene/gui/control.cpp (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x72987f1) (BuildId: 0ac95bb7ee94a1ce)
    #27 Control::_notificationv(int, bool) /opt/godot/./scene/gui/control.h:48:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x4c03ff5) (BuildId: 0ac95bb7ee94a1ce)
    #28 Container::_notificationv(int, bool) /opt/godot/./scene/gui/container.h:37:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x4c03ff5)
    #29 BoxContainer::_notificationv(int, bool) /opt/godot/./scene/gui/box_container.h:37:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x4c03ff5)
    #30 VBoxContainer::_notificationv(int, bool) /opt/godot/./scene/gui/box_container.h:90:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x4c03ff5)
    #31 Object::notification(int, bool) /opt/godot/core/object/object.cpp:837:3 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0xa112d33) (BuildId: 0ac95bb7ee94a1ce)
    #32 CanvasItem::_notification(int) /opt/godot/scene/main/canvas_item.cpp:322:5 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x6fafcc2) (BuildId: 0ac95bb7ee94a1ce)
    #33 CanvasItem::_notificationv(int, bool) /opt/godot/./scene/main/canvas_item.h:45:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x4c03feb) (BuildId: 0ac95bb7ee94a1ce)
    #34 Control::_notificationv(int, bool) /opt/godot/./scene/gui/control.h:48:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x4c03feb)
    #35 Container::_notificationv(int, bool) /opt/godot/./scene/gui/container.h:37:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x4c03feb)
    #36 BoxContainer::_notificationv(int, bool) /opt/godot/./scene/gui/box_container.h:37:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x4c03feb)
    #37 VBoxContainer::_notificationv(int, bool) /opt/godot/./scene/gui/box_container.h:90:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x4c03feb)
    #38 Object::notification(int, bool) /opt/godot/core/object/object.cpp:837:3 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0xa112d33) (BuildId: 0ac95bb7ee94a1ce)
    #39 Node::_propagate_enter_tree() /opt/godot/scene/main/node.cpp:262:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x704926c) (BuildId: 0ac95bb7ee94a1ce)
    #40 Node::_propagate_enter_tree() /opt/godot/scene/main/node.cpp:281:13 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x704942c) (BuildId: 0ac95bb7ee94a1ce)
    #41 Node::_set_tree(SceneTree*) /opt/godot/scene/main/node.cpp:3006:3 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x70516e4) (BuildId: 0ac95bb7ee94a1ce)
    #42 SceneTree::initialize() /opt/godot/scene/main/scene_tree.cpp:449:8 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x70aa528) (BuildId: 0ac95bb7ee94a1ce)
    #43 OS_LinuxBSD::run() /opt/godot/platform/linuxbsd/os_linuxbsd.cpp:933:13 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x3ba8f17) (BuildId: 0ac95bb7ee94a1ce)
    #44 main /opt/godot/platform/linuxbsd/godot_linuxbsd.cpp:74:6 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x3b99574) (BuildId: 0ac95bb7ee94a1ce)

  Mutex M0 previously acquired by the same thread here:
    #0 pthread_mutex_lock <null> (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x3b154b1) (BuildId: 0ac95bb7ee94a1ce)
    #1 __gthread_mutex_lock(pthread_mutex_t*) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/x86_64-pc-linux-gnu/bits/gthr-default.h:749:12 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x537e87f) (BuildId: 0ac95bb7ee94a1ce)
    #2 __gthread_recursive_mutex_lock(pthread_mutex_t*) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/x86_64-pc-linux-gnu/bits/gthr-default.h:811:10 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x537e87f)
    #3 std::recursive_mutex::lock() /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/mutex:120:17 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x537e87f)
    #4 std::unique_lock<std::recursive_mutex>::lock() /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/unique_lock.h:141:17 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x537e87f)
    #5 std::unique_lock<std::recursive_mutex>::unique_lock(std::recursive_mutex&) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/unique_lock.h:71:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x537e87f)
    #6 MutexLock<MutexImpl<std::recursive_mutex>>::MutexLock(MutexImpl<std::recursive_mutex> const&) /opt/godot/./core/os/mutex.h:81:4 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x537e87f)
    #7 TextServerAdvanced::_font_set_data_ptr(RID const&, unsigned char const*, long) /opt/godot/modules/text_server_adv/text_server_adv.cpp:1874:12 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x537e87f)
    #8 TextServerAdvanced::font_set_data_ptr(RID const&, unsigned char const*, long) /opt/godot/modules/text_server_adv/text_server_adv.h:729:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53d35ab) (BuildId: 0ac95bb7ee94a1ce)
    #9 FontFile::_ensure_rid(int, int) const /opt/godot/scene/resources/font.cpp:570:8 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x8006129) (BuildId: 0ac95bb7ee94a1ce)
    #10 FontFile::_get_rid() const /opt/godot/scene/resources/font.cpp:2330:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x7fecbf1) (BuildId: 0ac95bb7ee94a1ce)
    #11 Font::_update_rids_fb(Ref<Font> const&, int) const /opt/godot/scene/resources/font.cpp:108:18 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x7fbe71f) (BuildId: 0ac95bb7ee94a1ce)
    #12 Font::_update_rids() const /opt/godot/scene/resources/font.cpp:121:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x7fbe9c9) (BuildId: 0ac95bb7ee94a1ce)
    #13 Font::get_rids() const /opt/godot/scene/resources/font.cpp:185:3 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x7fbf3dd) (BuildId: 0ac95bb7ee94a1ce)
    #14 Label::_shape() /opt/godot/scene/gui/label.cpp:125:52 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x73dc112) (BuildId: 0ac95bb7ee94a1ce)
    #15 Label::get_minimum_size() const /opt/godot/scene/gui/label.cpp:795:30 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x73e2ceb) (BuildId: 0ac95bb7ee94a1ce)
    #16 Control::_update_minimum_size_cache() /opt/godot/scene/gui/control.cpp:1652:18 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x729dfcb) (BuildId: 0ac95bb7ee94a1ce)
    #17 Control::get_combined_minimum_size() const /opt/godot/scene/gui/control.cpp:1663:32 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x729dfcb)
    #18 PanelContainer::get_minimum_size() const /opt/godot/scene/gui/panel_container.cpp:46:22 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x746d1a4) (BuildId: 0ac95bb7ee94a1ce)
    #19 Control::_update_minimum_size_cache() /opt/godot/scene/gui/control.cpp:1652:18 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x729dfcb) (BuildId: 0ac95bb7ee94a1ce)
    #20 Control::get_combined_minimum_size() const /opt/godot/scene/gui/control.cpp:1663:32 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x729dfcb)
    #21 BoxContainer::get_minimum_size() const /opt/godot/scene/gui/box_container.cpp:267:20 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x71cdd16) (BuildId: 0ac95bb7ee94a1ce)
    #22 Control::_update_minimum_size_cache() /opt/godot/scene/gui/control.cpp:1652:18 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x729dfcb) (BuildId: 0ac95bb7ee94a1ce)
    #23 Control::get_combined_minimum_size() const /opt/godot/scene/gui/control.cpp:1663:32 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x729dfcb)
    #24 Control::_size_changed() /opt/godot/scene/gui/control.cpp:1681:23 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x728be35) (BuildId: 0ac95bb7ee94a1ce)
    #25 Control::_notification(int) /opt/godot/scene/gui/control.cpp (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x72987f1) (BuildId: 0ac95bb7ee94a1ce)
    #26 Control::_notificationv(int, bool) /opt/godot/./scene/gui/control.h:48:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x4c03ff5) (BuildId: 0ac95bb7ee94a1ce)
    #27 Container::_notificationv(int, bool) /opt/godot/./scene/gui/container.h:37:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x4c03ff5)
    #28 BoxContainer::_notificationv(int, bool) /opt/godot/./scene/gui/box_container.h:37:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x4c03ff5)
    #29 VBoxContainer::_notificationv(int, bool) /opt/godot/./scene/gui/box_container.h:90:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x4c03ff5)
    #30 Object::notification(int, bool) /opt/godot/core/object/object.cpp:837:3 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0xa112d33) (BuildId: 0ac95bb7ee94a1ce)
    #31 CanvasItem::_notification(int) /opt/godot/scene/main/canvas_item.cpp:322:5 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x6fafcc2) (BuildId: 0ac95bb7ee94a1ce)
    #32 CanvasItem::_notificationv(int, bool) /opt/godot/./scene/main/canvas_item.h:45:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x4c03feb) (BuildId: 0ac95bb7ee94a1ce)
    #33 Control::_notificationv(int, bool) /opt/godot/./scene/gui/control.h:48:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x4c03feb)
    #34 Container::_notificationv(int, bool) /opt/godot/./scene/gui/container.h:37:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x4c03feb)
    #35 BoxContainer::_notificationv(int, bool) /opt/godot/./scene/gui/box_container.h:37:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x4c03feb)
    #36 VBoxContainer::_notificationv(int, bool) /opt/godot/./scene/gui/box_container.h:90:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x4c03feb)
    #37 Object::notification(int, bool) /opt/godot/core/object/object.cpp:837:3 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0xa112d33) (BuildId: 0ac95bb7ee94a1ce)
    #38 Node::_propagate_enter_tree() /opt/godot/scene/main/node.cpp:262:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x704926c) (BuildId: 0ac95bb7ee94a1ce)
    #39 Node::_propagate_enter_tree() /opt/godot/scene/main/node.cpp:281:13 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x704942c) (BuildId: 0ac95bb7ee94a1ce)
    #40 Node::_set_tree(SceneTree*) /opt/godot/scene/main/node.cpp:3006:3 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x70516e4) (BuildId: 0ac95bb7ee94a1ce)
    #41 SceneTree::initialize() /opt/godot/scene/main/scene_tree.cpp:449:8 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x70aa528) (BuildId: 0ac95bb7ee94a1ce)
    #42 OS_LinuxBSD::run() /opt/godot/platform/linuxbsd/os_linuxbsd.cpp:933:13 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x3ba8f17) (BuildId: 0ac95bb7ee94a1ce)
    #43 main /opt/godot/platform/linuxbsd/godot_linuxbsd.cpp:74:6 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x3b99574) (BuildId: 0ac95bb7ee94a1ce)

  Mutex M0 acquired here while holding mutex M1 in main thread:
    #0 pthread_mutex_lock <null> (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x3b154b1) (BuildId: 0ac95bb7ee94a1ce)
    #1 __gthread_mutex_lock(pthread_mutex_t*) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/x86_64-pc-linux-gnu/bits/gthr-default.h:749:12 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x536f1fb) (BuildId: 0ac95bb7ee94a1ce)
    #2 __gthread_recursive_mutex_lock(pthread_mutex_t*) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/x86_64-pc-linux-gnu/bits/gthr-default.h:811:10 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x536f1fb)
    #3 std::recursive_mutex::lock() /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/mutex:120:17 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x536f1fb)
    #4 std::unique_lock<std::recursive_mutex>::lock() /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/unique_lock.h:141:17 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x536f1fb)
    #5 std::unique_lock<std::recursive_mutex>::unique_lock(std::recursive_mutex&) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/unique_lock.h:71:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x536f1fb)
    #6 MutexLock<MutexImpl<std::recursive_mutex>>::MutexLock(MutexImpl<std::recursive_mutex> const&) /opt/godot/./core/os/mutex.h:81:4 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x536f1fb)
    #7 TextServerAdvanced::_free_rid(RID const&) /opt/godot/modules/text_server_adv/text_server_adv.cpp:397:14 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x536f1fb)
    #8 TextServerAdvanced::free_rid(RID const&) /opt/godot/modules/text_server_adv/text_server_adv.h:710:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53d32aa) (BuildId: 0ac95bb7ee94a1ce)
    #9 FontFile::_clear_cache() /opt/godot/scene/resources/font.cpp:555:8 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x80059e4) (BuildId: 0ac95bb7ee94a1ce)
    #10 FontFile::~FontFile() /opt/godot/scene/resources/font.cpp:2732:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x7ff377d) (BuildId: 0ac95bb7ee94a1ce)
    #11 void memdelete<Font>(Font*) /opt/godot/./core/os/memory.h:116:13 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x86dbe30) (BuildId: 0ac95bb7ee94a1ce)
    #12 Ref<Font>::unref() /opt/godot/./core/object/ref_counted.h:210:4 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x86dbe30)
    #13 ThemeDB::~ThemeDB() /opt/godot/scene/theme/theme_db.cpp:464:16 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x86dbe30)
    #14 void memdelete<ThemeDB>(ThemeDB*) /opt/godot/./core/os/memory.h:116:13 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x3cd92a2) (BuildId: 0ac95bb7ee94a1ce)
    #15 finalize_theme_db() /opt/godot/main/main.cpp:378:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x3cd92a2)
    #16 Main::cleanup(bool) /opt/godot/main/main.cpp:4116:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x3cd92a2)
    #17 main /opt/godot/platform/linuxbsd/godot_linuxbsd.cpp:76:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x3b9957b) (BuildId: 0ac95bb7ee94a1ce)

  Mutex M1 previously acquired by the same thread here:
    #0 pthread_mutex_lock <null> (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x3b154b1) (BuildId: 0ac95bb7ee94a1ce)
    #1 __gthread_mutex_lock(pthread_mutex_t*) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/x86_64-pc-linux-gnu/bits/gthr-default.h:749:12 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x536f12f) (BuildId: 0ac95bb7ee94a1ce)
    #2 __gthread_recursive_mutex_lock(pthread_mutex_t*) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/x86_64-pc-linux-gnu/bits/gthr-default.h:811:10 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x536f12f)
    #3 std::recursive_mutex::lock() /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/mutex:120:17 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x536f12f)
    #4 std::unique_lock<std::recursive_mutex>::lock() /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/unique_lock.h:141:17 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x536f12f)
    #5 std::unique_lock<std::recursive_mutex>::unique_lock(std::recursive_mutex&) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/unique_lock.h:71:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x536f12f)
    #6 MutexLock<MutexImpl<std::recursive_mutex>>::MutexLock(MutexImpl<std::recursive_mutex> const&) /opt/godot/./core/os/mutex.h:81:4 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x536f12f)
    #7 TextServerAdvanced::_free_rid(RID const&) /opt/godot/modules/text_server_adv/text_server_adv.cpp:393:13 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x536f12f)
    #8 TextServerAdvanced::free_rid(RID const&) /opt/godot/modules/text_server_adv/text_server_adv.h:710:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x53d32aa) (BuildId: 0ac95bb7ee94a1ce)
    #9 FontFile::_clear_cache() /opt/godot/scene/resources/font.cpp:555:8 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x80059e4) (BuildId: 0ac95bb7ee94a1ce)
    #10 FontFile::~FontFile() /opt/godot/scene/resources/font.cpp:2732:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x7ff377d) (BuildId: 0ac95bb7ee94a1ce)
    #11 void memdelete<Font>(Font*) /opt/godot/./core/os/memory.h:116:13 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x86dbe30) (BuildId: 0ac95bb7ee94a1ce)
    #12 Ref<Font>::unref() /opt/godot/./core/object/ref_counted.h:210:4 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x86dbe30)
    #13 ThemeDB::~ThemeDB() /opt/godot/scene/theme/theme_db.cpp:464:16 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x86dbe30)
    #14 void memdelete<ThemeDB>(ThemeDB*) /opt/godot/./core/os/memory.h:116:13 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x3cd92a2) (BuildId: 0ac95bb7ee94a1ce)
    #15 finalize_theme_db() /opt/godot/main/main.cpp:378:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x3cd92a2)
    #16 Main::cleanup(bool) /opt/godot/main/main.cpp:4116:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x3cd92a2)
    #17 main /opt/godot/platform/linuxbsd/godot_linuxbsd.cpp:76:2 (godot.linuxbsd.editor.dev.x86_64.llvm.san+0x3b9957b) (BuildId: 0ac95bb7ee94a1ce)

SUMMARY: ThreadSanitizer: lock-order-inversion (potential deadlock) (/opt/godot/bin/godot.linuxbsd.editor.dev.x86_64.llvm.san+0x3b154b1) (BuildId: 0ac95bb7ee94a1ce) in pthread_mutex_lock
==================

As noted in #72646 (comment), these TextServer deadlock warnings seem to be currently supressed in CI:

deadlock:modules/text_server_adv/text_server_adv.cpp
deadlock:modules/text_server_fb/text_server_fb.cpp

I don't think they should be -- although hard to reproduce, the same deadlock MRP (deadlock_mrp.zip) sometimes show Object leaks related to TextServerAdvanced which I suppose are related to these deadlocks holding resources it shouldn't. More commonly, however, some RefCounted objects seem to get held in memory as well and reported as leaked when they shouldn't be. This also happens with the same deadlock MRP sometimes where DialogueEngine (which extends RefCounted) gets leaked but it shouldn't -- I don't think there's any cyclic reference against DialogueEngine either that could explain it getting leaked from time to time.

@Rubonnek Rubonnek changed the title Lock-order-inversion warning by ThreadSanitizer upon opening and closing the Editor Lock-order-inversion detected by ThreadSanitizer in TextServerAdvanced Feb 7, 2024
@Rubonnek
Copy link
Member Author

Rubonnek commented Feb 7, 2024

CC @bruvzg

@bruvzg
Copy link
Member

bruvzg commented Feb 9, 2024

I'll re-check and try to simplify #72646 next week, it was fixing lock order but had some performance impact (and there were no reproducible issues related to it, apart from thread sanitizer report).

@bruvzg bruvzg self-assigned this Feb 9, 2024
@bruvzg bruvzg linked a pull request Feb 12, 2024 that will close this issue
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.

4 participants