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

Deadlock on thread if "wait_to_finish" has been called by the parent thread and child executes Texture2D.get_image() #74081

Closed
JohnPandich opened this issue Feb 27, 2023 · 2 comments
Labels

Comments

@JohnPandich
Copy link

Godot version

v4.0.rc6

System information

Linux Mint, Forward+, ntel© Xeon© CPU E5-2650 v4 @ 2.20GHz × 12, 64gb ram

Issue description

A thread will be deadlocked when executing Texture2D.get_image() if and only if the parent thread has called Thread.wait_to_finish() on the child thread.

I would expect the thread to execute as normal.

Steps to reproduce

  1. spawn child thread
  2. start execution of child
  3. execute wait_to_finish() on the child thread
  4. execute "get_image()" on a Texture2D in the child thread

Minimal reproduction project

repro.zip

@JohnPandich JohnPandich changed the title Deadlock on thread if "wait_to_finish" has been called on the parent thread. Deadlock on thread if "wait_to_finish" has been called by the parent thread and child executes Texture2D.get_image() Feb 27, 2023
@Jimmio92
Copy link

Threads aren't implemented correctly #71408 and my changes that needed work so I closed #71097

Basically, they're detaching always in the destructor, so when the thread function returns, it detaches and cleans up automatically. This means you cannot call wait_to_finish on it (which is a join, btw). Joining a thread pauses the current thread's execution until the other thread is done.

Yes, it warns you must always call it, but good luck calling join on a detached and dead thread, which is an error, because it erroneously treats an invalid handle as the main thread, and you can't join the main thread from the main thread.

@JohnPandich
Copy link
Author

thanks Jimmio! Closing as a duplicate of #71097

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

No branches or pull requests

3 participants