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

WorkerThreadPool doesn't call ScriptServer::thread_exit() #95809

Closed
CedNaru opened this issue Aug 19, 2024 · 1 comment · Fixed by #96760 or #96959
Closed

WorkerThreadPool doesn't call ScriptServer::thread_exit() #95809

CedNaru opened this issue Aug 19, 2024 · 1 comment · Fixed by #96760 or #96959
Milestone

Comments

@CedNaru
Copy link
Contributor

CedNaru commented Aug 19, 2024

Tested versions

Godot 4.3 stable

System information

Windows 10

Issue description

We are upgrading our Kotlin language binding to Godot 4.3, but the engine doesn't want to close anymore.
Before our embedded JVM can close, it waits for all "attached" threads to be closed.
We usually attach/detach threads to the JVM using the callback ScriptServer::thread_enter / ScriptServer::thread_exit.

It seems that a recent change to WorkerThreadPool makes all threads call ScriptServer::thread_enter (in a delayed manner because the pool is initialized before the ScriptServer). The issue seems to be that ScriptServer::thread_exit is never called by it before the ScriptServer is terminated. Instead, it only happens when the pool threads are deleted as part of the WorkerThreadPool's destructor, which happens in the very last steps of Main::cleanup.
I also can't find any callbacks that would be executed this late either (MessageQueue is freed before the pool as well).

I'm not certain that this is the source of our issue but we confirmed that we received more thread_enter calls than thread_exit calls. So it's either the pool, or some mysterious other thread somewhere in Godot that is not terminated in time.

@RandomShaper

Steps to reproduce

Minimal reproduction project (MRP)

@AThousandShips
Copy link
Member

The enter was added in:

But without corresponding exit, wasn't discussed specifically there

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