godotengine / godotengine/godot
HotReload with threads causes crashes
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
4.2.x
### System information
Windows 10
### Issue description
If you have multiple (looping) background threads, hot reloading seems to corrupt the Script VM state. This results in all manner of strange errors. I have seen:
- Method [corrupted string] does not exist on SceneTree
- Bad address
- Invalid opcode
- outright crash
With a single thread this is quite rare. With the 5 threads in the demo project I get it quite consistently.
### Steps to reproduce
- Run the attached demo project
- Change some code in the Thread.gd file
- 90% chance of a crash/error
### Minimal reproduction project (MRP)
[Thread.zip](https://github.com/godotengine/godot/files/13941778/Thread.zip)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the attached Thread.zip demo on Windows 10, then edit Thread.gd while its looping background threads are active to reproduce the crash or Script VM errors. Trace the hot-reload and threading entry points involved in the reproduction; done means repeated edits no longer corrupt the VM or crash the engine.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100