Repository: godot
Issue: Multithread rendering cause almost instant crash in `CommandQueueMT::allocate_and_lock`
Labels: bug,topic:rendering,crash,regression

### Godot version

4.0.dev.custom_build. 43e96e0c6

### System information

Ubuntu 21.04 - Nvidia GTX 970, Gnome shell 3.38 X11

### Issue description

Running test project crash without any message(this worked fine ~5 months ago)
This is backtrace from GDB
```
#0  futex_wait (private=0, expected=2, futex_word=0xb55f770) at ../sysdeps/nptl/futex-internal.h:146
#1  __lll_lock_wait (futex=futex@entry=0xb55f770, private=0) at lowlevellock.c:52
#2  0x00007ffff7db97b0 in __GI___pthread_mutex_lock (mutex=0xb55f770) at ../nptl/pthread_mutex_lock.c:115
#3  0x0000000002213167 in __gthread_mutex_lock (__mutex=0xb55f770) at /usr/include/x86_64-linux-gnu/c++/10/bits/gthr-default.h:749
#4  0x00000000022131e6 in __gthread_recursive_mutex_lock (__mutex=0xb55f770) at /usr/include/x86_64-linux-gnu/c++/10/bits/gthr-default.h:811
#5  0x0000000002213396 in std::recursive_mutex::lock (this=0xb55f770) at /usr/include/c++/10/mutex:106
#6  0x0000000006594780 in MutexImpl<std::recursive_mutex>::lock (this=0xb55f770) at ./core/os/mutex.h:47
#7  CommandQueueMT::lock (this=0xb55f420) at core/templates/command_queue_mt.cpp:37
#8  0x0000000005b6def0 in CommandQueueMT::allocate_and_lock<CommandQueueMT::Command1<RendererCanvasCull, void (RendererCanvasCull::*)(RID), RID> > (
    this=0xb55f420) at ./core/templates/command_queue_mt.h:357
#9  0x0000000005b673b9 in CommandQueueMT::push<RendererCanvasCull, void (RendererCanvasCull::*)(RID), RID> (this=0xb55f420, p_instance=0xb571680, p_method=
    (void (RendererCanvasCull::*)(RendererCanvasCull * const, RID)) 0x5da37bc <RendererCanvasCull::canvas_item_clear(RID)>, p1=...)
    at ./core/templates/command_queue_mt.h:392
#10 0x0000000005b5807a in RenderingServerDefault::canvas_item_clear (this=0xb55f2b0, p1=...) at servers/rendering/rendering_server_default.h:784
#11 0x00000000049aefa1 in CanvasItem::_update_callback (this=0xd5fbf80) at scene/main/canvas_item.cpp:143
#12 0x00000000024708e6 in call_with_variant_args_helper<__UnexistingClass>(__UnexistingClass*, void (__UnexistingClass::*)(), Variant const**, Callable::CallError&, IndexSequence<>) (p_instance=0xd5fbf80, p_method=(void (__UnexistingClass::*)(__UnexistingClass * const)) 0x49aef24 <CanvasItem::_update_callback()>, 
    p_args=0x7fffffffd540, r_error=...) at ./core/variant/binder_common.h:222
#13 0x000000000246ff11 in call_with_variant_args_dv<__UnexistingClass> (p_instance=0xd5fbf80, 
    p_method=(void (__UnexistingClass::*)(__UnexistingClass * const)) 0x49aef24 <CanvasItem::_update_callback()>, p_args=0x0, p_argcount=0, r_error=..., 
    default_values=...) at ./core/variant/binder_common.h:369
#14 0x000000000246ebb2 in MethodBindT<>::call(Object*, Variant const**, int, Callable::CallError&) (this=0xcbc9fc0, p_object=0xd5fbf80, p_args=0x0, 
    p_arg_count=0, r_error=...) at ./core/object/method_bind.h:286
#15 0x000000000656af2c in Object::call (this=0xd5fbf80, p_method=..., p_args=0x0, p_argcount=0, r_error=...) at core/object/object.cpp:832
#16 0x00000000062b9ee7 in Callable::call (this=0x7fffede67020, p_arguments=0x0, p_argcount=0, r_return_value=..., r_call_error=...)
    at core/variant/callable.cpp:62
#17 0x0000000006563822 in MessageQueue::_call_function (this=0xacdb8c0, p_callable=..., p_args=0x7fffede67038, p_argcount=0, p_show_error=false)
    at core/object/message_queue.cpp:258
#18 0x0000000006563b76 in MessageQueue::flush (this=0xacdb8c0) at core/object/message_queue.cpp:304
#19 0x000000000224f6c5 in Main::iteration () at main/main.cpp:2521
#20 0x000000000220d214 in OS_LinuxBSD::run (this=0x7fffffffda60) at platform/linuxbsd/os_linuxbsd.cpp:342
#21 0x00000000022095bc in main (argc=1, argv=0x7fffffffdf58) at platform/linuxbsd/godot_linuxbsd.cpp:58
```

### Steps to reproduce

Run minimal project

### Minimal reproduction project

[RegressionTestProject.zip](https://github.com/godotengine/godot/files/7163517/RegressionTestProject.zip)