Repository: godot
Issue: Lock-order-inversion detected by ThreadSanitizer in `TextServerAdvanced`
Labels: bug,topic:editor

### Tested versions

63d6bda8e95ac992da74e84b2f3be62f3d85190b - reproducible

### System information

Godot v4.3.dev (63d6bda8e) - 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: 
```bash
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
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"])
```
2. 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:
```bash
sudo sysctl vm.mmap_rnd_bits=28
# reverse it with: sudo sysctl vm.mmap_rnd_bits=32
```
OR disable ASLR entirely temporarily :
```bash
sudo sysctl kernel.randomize_va_space=0
# reverse it with:sudo sysctl kernel.randomize_va_space=2
```

3. The following ThreadSanitizer warning should appear:
```tsan
==================
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](https://github.com/godotengine/godot/files/14171510/EmptyProject.zip)