Quick answer: Godot 4 GDScript Array.push_back crashing when called from a worker thread? Arrays aren't thread-safe - use a Mutex or post messages via call_deferred.

Background worker collects results. Random crash on push_back: Attempt to use Array from multiple threads.

Guard with a Mutex

mutex.lock()
results.push_back(value)
mutex.unlock()

Explicit lock around every shared-state write. Read on main thread after the worker signals completion.

Or defer to main

main_node.call_deferred("add_result", value). Avoids the mutex; pays for it in deferred-call overhead.

Use Thread-safe data structures

Godot's SemaphoreMutex and WorkerThreadPool handle most patterns. Roll your own only when those don't fit.

“GDScript Arrays are not thread-safe. Either lock them or don't share them.”

For one-direction worker-to-main communication, the deferred call pattern beats explicit mutexes. Less to get wrong, easier to read.