Using rendy on multiple threads at same time causes segfault
- Lingua principale
- Rust
- Stelle
- 812
- Fork
- 94
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
### Symptom
Given:
* 2 or more threads
* each thread uses `rendy` at the same time
Then sometimes one thread's resource cleanup interferes with the other thread's usage.
### Steps to Reproduce
This crate just has 100 test functions with an empty `GraphBuilder`
```bash
git clone git@github.com:azriel91/amethyst_rendy_test.git
cd amethyst_rendy_test
cargo update # in case you already had it
cargo test -- --nocapture
# should segfault, if not run it again
# proof that it doesn't segfault with 1 thread:
cargo test -- --nocapture --test-threads 1
```
### Theory
Multiple threads share a common "memory space" (? I don't understand `rendy` enough). When one is cleaning up, another might be setting up, causing `Terminal` to be disposed while some `Escape` values are created.
**Note:**
When run single threaded (`cargo test -- --test-threads 1`) with the empty graph, it doesn't segfault.
Further evidence that rendy is correctly disposing in the correct order if you follow the serial control flow.
When run single threaded with `RenderTestBundle`, which has the sprites and `PresentNode` in the graph, it *does* segfault.
### Logs
```markdown
...
[ERROR][rendy_resource::escape] Terminal must be dropped after all `Escape`s
[ERROR][rendy_resource::escape] Terminal must be dropped after all `Escape`s
[ERROR][rendy_memory::allocator::dynamic] Memory leak: SizeEntry(8192) is still used
[ERROR][rendy_memory::allocator::dynamic] Memory leak: SizeEntry(1024) is still used
[ERROR][rendy_memory::allocator::dynamic] Memory leak: SizeEntry(65536) is still used
[ERROR][rendy_memory::allocator::dynamic] Memory leak: SizeEntry(524288) is still used
[ERROR][rendy_memory::allocator::dynamic] Memory leak: SizeEntry(4194304) is still used
[ERROR][rendy_resource::escape] `Escape` was dropped after a `Terminal`?
...
```
### Environment
* OS: Windows
* Rendy version: `master`
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.