amethyst / amethyst/rendy

Using rendy on multiple threads at same time causes segfault

Abierto
#151 4 comentarios 1 reacción 0 asignados Ver en GitHub
bug diff: hard
Lenguaje dominante
Rust
Estrellas
812
Forks
94
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

### 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`

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.