Skip to content

Deadlock when exiting and using Multithreaded renderer #96931

Closed
@clayjohn

Description

@clayjohn

Tested versions

  • Master (anything after 2d1dd41)
  • 4.4 dev2 (does not reproduce)

System information

Godot v4.4.dev (2d1dd41) - Pop!_OS 22.04 LTS - X11 - Vulkan (Forward+) - integrated Intel(R) Xe Graphics (TGL GT2) - 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz (8 Threads)

Issue description

The WorkerThreadPool deadlocks in the main::cleanup() function during shutdown.

This is a regression and I bisected it to 2d1dd41

#96760 makes it so the WTP is finalized before the servers have a chance to shut down. When using the MT thread model, the servers yield to the WTP until a command is pushed to them.

During finalizing, the WTP waits for all threads to finish, this locks the main thread. However, the command to finalize the rendering thread happens after the WTP finalizes. So the main thread gets stuck indefinitely.

This bug also impacts any other system that creates a long running thread through the WTP and relies on yielding.

Steps to reproduce

  1. Enabled the Multi thread rendering model
  2. Run the project
  3. Try to close the project

Minimal reproduction project (MRP)

mt-deadlock.zip

Metadata

Metadata

Assignees

Type

No type

Projects

  • Status

    Immediate Blocker

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions