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

Crash when loading translations with ResourceLoader.load_threaded_request #98577

Open
Dragoncraft89 opened this issue Oct 27, 2024 · 0 comments

Comments

@Dragoncraft89
Copy link
Contributor

Dragoncraft89 commented Oct 27, 2024

Tested versions

Reproducible: 4.3-stable, master (d3298fe)

Does not occur in 4.2 and earlier

System information

Godot v4.4.dev (d3298fe) - Ubuntu 22.04.5 LTS 22.04 on X11 - X11 display driver, Multi-window, 2 monitors - Vulkan (Forward+) - dedicated AMD Radeon RX 7800 XT (RADV GFX1101) - AMD Ryzen 7 7800X3D 8-Core Processor (16 threads)

Issue description

Loading translation files with ResourceLoader.load_threaded_request crashes the game.

Backtrace from inside gdb:

#0  HashMap<StringName, HashMap<StringName, Ref<Texture2D>, HashMapHasherDefault, HashMapComparatorDefault<StringName>, DefaultTypedAllocator<HashMapElement<StringName, Ref<Texture2D> > > >, HashMapHasherDefault, HashMapComparatorDefault<StringName>, DefaultTypedAllocator<HashMapElement<StringName, HashMap<StringName, Ref<Texture2D>, HashMapHasherDefault, HashMapComparatorDefault<StringName>, DefaultTypedAllocator<HashMapElement<StringName, Ref<Texture2D> > > > > > >::clear (this=0x55555cbc8ee0) at ./core/templates/hash_map.h:267
#1  HashMap<StringName, HashMap<StringName, Ref<Texture2D>, HashMapHasherDefault, HashMapComparatorDefault<StringName>, DefaultTypedAllocator<HashMapElement<StringName, Ref<Texture2D> > > >, HashMapHasherDefault, HashMapComparatorDefault<StringName>, DefaultTypedAllocator<HashMapElement<StringName, HashMap<StringName, Ref<Texture2D>, HashMapHasherDefault, HashMapComparatorDefault<StringName>, DefaultTypedAllocator<HashMapElement<StringName, Ref<Texture2D> > > > > > >::clear (this=0x55555cbc8ee0) at ./core/templates/hash_map.h:256
#2  Window::_invalidate_theme_cache (this=0x55555cbc8390) at scene/main/window.cpp:2087
#3  0x0000555556e47ebd in Window::_notification (this=0x55555cbc8390, p_what=<optimized out>) at scene/main/window.cpp:1393
#4  0x0000555558c6a758 in Object::notification (this=0x55555cbc8390, p_notification=2010, p_reversed=<optimized out>) at core/object/object.cpp:875
#5  0x0000555556d7d67b in Node::propagate_notification (this=0x55555cbc8390, p_notification=2010) at scene/main/node.cpp:2494
#6  0x0000555558c6a758 in Object::notification (this=0x55555cbc7db0, p_notification=2010, p_reversed=<optimized out>) at core/object/object.cpp:875
#7  0x0000555558c65327 in CallQueue::_call_function (this=this@entry=0x7fffa0000c00, p_callable=..., p_args=p_args@entry=0x7fffa00152a8, p_argcount=0, p_show_error=<optimized out>) at core/object/message_queue.cpp:220
#8  0x0000555558c65775 in CallQueue::flush (this=0x7fffa0000c00) at core/object/message_queue.cpp:268
#9  0x00005555588cbd54 in ResourceLoader::_run_load_task (p_userdata=0x55555cd025e8) at core/io/resource_loader.cpp:356
#10 0x0000555558caa2f5 in WorkerThreadPool::_process_task (this=0x55555a4890a0, p_task=p_task@entry=0x55555ce6a648) at core/object/worker_thread_pool.cpp:137
#11 0x0000555558caa862 in WorkerThreadPool::_thread_function (p_user=0x55555a51ac60) at core/object/worker_thread_pool.cpp:205
#12 0x0000555558706095 in Thread::callback (p_caller_id=<optimized out>, p_settings=..., p_callback=0x555558caa740 <WorkerThreadPool::_thread_function(void*)>, p_userdata=0x55555a51ac60) at core/os/thread.cpp:64
#13 0x0000555559173404 in execute_native_thread_routine ()
#14 0x00007ffff7c94ac3 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#15 0x00007ffff7d26850 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

The crash occurs during a notification of type NOTIFICATION_TRANSLATION_CHANGED (p_notification=2010), which forces ui controls to rebuild the theme cache. I presume this is some form of race condition.

The commit that introduces this crash is 5cb9a74 (from #91630), although I do not see any immediate relation between the changes and the above backtrace.

Steps to reproduce

Start the attached MRP and click on the Click to crash button

There seem to be some preconditions for the crash to occur:

  1. load multiple translations in different threads simultaneously. One does not seem to be enough
  2. In the project settings, there must be multiple translations already loaded. Otherwise, the crash doesn't occur
  3. The crash seems to be somewhat unreliable. If I reduce the number of translations then the game only crashes sometimes. With many translations the crash is consistent for me
  4. Additionally, the translations need some content. If the translation files are mostly empty, the crash doesn't occur. I added some translation files from my project that trigger the crash

Minimal reproduction project (MRP)

threaded_translation_bug.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant