amethyst/evoli

[BUG] Evoli crashes after unspecified time

joarfish opened this issue · 9 comments

Description

Evoli crashes after running for unspecific time (can be a few seconds, sometimes 10minutes). This happens even without any interaction.

Reproduction Steps

  1. clone evoli master
  2. cargo run
  3. wait until it crashes

My Environment

  • macos 10.14.4
  • cargo 1.34.0 (6789d8a0a 2019-04-01)
  • rustc 1.34.2 (6c2484dc3 2019-05-13)

What You Expected to Happen

Evoli runs until I close it.

What Actually Happened

Evoli panics with this message:

thread '<unnamed>' panicked at 'Entity Entity(13, Generation(4)) had a non-finite Transform', /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/amethyst_core-0.5.0/src/transform/systems.rs:105:13

Additional Context

I tried to debug the issue and found that if you remove the Ixies from the game it does not crash. As the backtrace (see below) indicates there seems to be a problem with transforming the isometry to a matrix in the amethyst's transform system. So, maybe someting with the parenting of Ixie swarmlings triggers the crash.

Of course this might just as well be a problem with amethyst 0.10.0. I did not try to compile evoli with the current master of amethyst.

Backtrace

thread '<unnamed>' panicked at 'Entity Entity(15, Generation(5)) had a non-finite `Transform`', /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/amethyst_core-0.5.0/src/transform/systems.rs:105:13
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
   1: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:70
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/sys_common/backtrace.rs:58
             at src/libstd/panicking.rs:200
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:215
   4: <std::panicking::begin_panic::PanicPayload<A> as core::panic::BoxMeUp>::get
             at src/libstd/panicking.rs:478
   5: <alloc::string::String as core::ops::index::Index<core::ops::range::RangeFull>>::index
             at /rustc/6c2484dc3c532c052f159264e970278d8b77cdc9/src/libstd/panicking.rs:412
   6: hibitset::BitSet::contains
             at /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/amethyst_core-0.5.0/src/transform/systems.rs:105
   7: <hibitset::BitSet as core::clone::Clone>::clone
             at /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/shred-0.7.2/src/system.rs:133
   8: shred::dispatch::stage::Stage::execute::{{closure}}
             at /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/shred-0.7.2/src/dispatch/stage.rs:104
   9: rayon_core::latch::SpinLatch::new
             at /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.0.3/src/iter/for_each.rs:49
  10: <shred::dispatch::stage::StagesBuilder<'a> as core::default::Default>::default
             at /rustc/6c2484dc3c532c052f159264e970278d8b77cdc9/src/libcore/slice/mod.rs:3003
  11: rayon_core::latch::SpinLatch::new
             at /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.0.3/src/iter/for_each.rs:49
  12: <fxhash::FxHasher as core::default::Default>::default
             at /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.0.3/src/iter/plumbing/mod.rs:108
  13: rayon::iter::plumbing::LengthSplitter::try
             at /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.0.3/src/iter/plumbing/mod.rs:418
  14: rayon::iter::plumbing::LengthSplitter::try
             at /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.0.3/src/iter/plumbing/mod.rs:410
  15: core::ptr::swap_nonoverlapping_bytes
             at /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.4.1/src/join/mod.rs:128
  16: <shred::res::Resources as core::default::Default>::default
             at /rustc/6c2484dc3c532c052f159264e970278d8b77cdc9/src/libstd/panic.rs:309
  17: core::alloc::Layout::repeat
             at /rustc/6c2484dc3c532c052f159264e970278d8b77cdc9/src/libstd/panicking.rs:297
  18: panic_unwind::dwarf::eh::read_encoded_pointer
             at src/libpanic_unwind/lib.rs:87
  19: core::alloc::Layout::repeat
             at /rustc/6c2484dc3c532c052f159264e970278d8b77cdc9/src/libstd/panicking.rs:276
  20: rayon_core::FnContext::migrated
             at /rustc/6c2484dc3c532c052f159264e970278d8b77cdc9/src/libstd/panic.rs:388
  21: <alloc::collections::CollectionAllocErr as core::convert::From<core::alloc::LayoutErr>>::from
             at /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.4.1/src/unwind.rs:18
  22: core::ptr::swap_nonoverlapping_bytes
             at /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.4.1/src/join/mod.rs:128
  23: rayon_core::registry::WORKER_THREAD_STATE::__init
             at /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.4.1/src/registry.rs:705
  24: core::ptr::swap_nonoverlapping_bytes
             at /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.4.1/src/join/mod.rs:116
  25: rayon::iter::plumbing::LengthSplitter::try
             at /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.0.3/src/iter/plumbing/mod.rs:409
  26: rayon::iter::plumbing::LengthSplitter::try
             at /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.0.3/src/iter/plumbing/mod.rs:391
  27: rayon_core::latch::SpinLatch::new
             at /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.0.3/src/iter/plumbing/mod.rs:368
  28: <shred::res::Resources as core::default::Default>::default
             at /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.0.3/src/slice/mod.rs:692
  29: rayon::iter::plumbing::LengthSplitter::try
             at /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.0.3/src/iter/plumbing/mod.rs:351
  30: <fxhash::FxHasher as core::default::Default>::default
             at /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.0.3/src/slice/mod.rs:670
  31: alloc::string::String::push_str
             at /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.0.3/src/iter/for_each.rs:11
  32: <fxhash::FxHasher as core::default::Default>::default
             at /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.0.3/src/iter/mod.rs:345
  33: shred::dispatch::stage::Stage::setup
             at /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/shred-0.7.2/src/dispatch/stage.rs:102
  34: shred::dispatch::dispatcher::Dispatcher::dispatch_par::{{closure}}
             at /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/shred-0.7.2/src/dispatch/dispatcher.rs:87
  35: <alloc::collections::CollectionAllocErr as core::convert::From<core::alloc::LayoutErr>>::from
             at /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.4.1/src/thread_pool/mod.rs:124
  36: rayon_core::registry::WORKER_THREAD_STATE::__init
             at /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.4.1/src/registry.rs:356
  37: <rayon_core::job::JobRef as core::cmp::PartialEq>::eq
             at /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.4.1/src/job.rs:113
  38: <shred::res::Resources as core::default::Default>::default
             at /rustc/6c2484dc3c532c052f159264e970278d8b77cdc9/src/libstd/panic.rs:309
  39: core::alloc::Layout::repeat
             at /rustc/6c2484dc3c532c052f159264e970278d8b77cdc9/src/libstd/panicking.rs:297
  40: panic_unwind::dwarf::eh::read_encoded_pointer
             at src/libpanic_unwind/lib.rs:87
  41: core::alloc::Layout::repeat
             at /rustc/6c2484dc3c532c052f159264e970278d8b77cdc9/src/libstd/panicking.rs:276
  42: rayon_core::FnContext::migrated
             at /rustc/6c2484dc3c532c052f159264e970278d8b77cdc9/src/libstd/panic.rs:388
  43: <alloc::collections::CollectionAllocErr as core::convert::From<core::alloc::LayoutErr>>::from
             at /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.4.1/src/unwind.rs:18
  44: <rayon_core::job::JobRef as core::cmp::PartialEq>::eq
             at /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.4.1/src/job.rs:113
  45: rayon_core::job::JobRef::execute
             at /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.4.1/src/job.rs:60
  46: rayon_core::registry::WorkerThread::wait_until_cold::{{closure}}
             at /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.4.1/src/registry.rs:584
  47: rayon_core::registry::WorkerThread::take_local_job
             at /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.4.1/src/registry.rs:568
  48: rayon_core::registry::WorkerThread::take_local_job
             at /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.4.1/src/registry.rs:544
  49: rayon_core::registry::main_loop
             at /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.4.1/src/registry.rs:666
  50: rayon_core::registry::Registry::new::{{closure}}
             at /Users/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.4.1/src/registry.rs:135
  51: <alloc::collections::CollectionAllocErr as core::convert::From<core::alloc::AllocErr>>::from
             at /rustc/6c2484dc3c532c052f159264e970278d8b77cdc9/src/libstd/sys_common/backtrace.rs:135
  52: <alloc::vec::SetLenOnDrop<'_> as core::ops::drop::Drop>::drop
             at /rustc/6c2484dc3c532c052f159264e970278d8b77cdc9/src/libstd/thread/mod.rs:469
  53: alloc::raw_vec::alloc_guard
             at /rustc/6c2484dc3c532c052f159264e970278d8b77cdc9/src/libstd/panic.rs:309
  54: std::thread::panicking
             at /rustc/6c2484dc3c532c052f159264e970278d8b77cdc9/src/libstd/panicking.rs:297
  55: panic_unwind::dwarf::eh::read_encoded_pointer
             at src/libpanic_unwind/lib.rs:87
  56: std::thread::panicking
             at /rustc/6c2484dc3c532c052f159264e970278d8b77cdc9/src/libstd/panicking.rs:276
  57: std::sys::unix::condvar::Condvar::wait
             at /rustc/6c2484dc3c532c052f159264e970278d8b77cdc9/src/libstd/panic.rs:388
  58: <alloc::vec::SetLenOnDrop<'_> as core::ops::drop::Drop>::drop
             at /rustc/6c2484dc3c532c052f159264e970278d8b77cdc9/src/libstd/thread/mod.rs:468
  59: core::hash::sip::u8to64_le
             at /rustc/6c2484dc3c532c052f159264e970278d8b77cdc9/src/liballoc/boxed.rs:749
  60: std::sys::unix::thread::Thread::new::thread_start
             at /rustc/6c2484dc3c532c052f159264e970278d8b77cdc9/src/liballoc/boxed.rs:759
             at src/libstd/sys_common/thread.rs:14
             at src/libstd/sys/unix/thread.rs:81
  61: _pthread_body
  62: _pthread_start

I've never had that issue, even when letting the game run for a while. Did you use the Speed Up button to accelerate the game ? That might break some things.

I encountered that too, but I think only while using a speed up. I think the non-finite transform part can happen when we have a divided by 0 coordinate.

Definitely, something we should investigate. Thanks for reporting!

The speed up button increases the time scale indefinitely. If you click it a lot, the time step of each update becomes so large that entities start jumping out of world bounds and stuff starts breaking down. We should find a way to mitigate that.

We could implement the speed up as making several dispatches in a single update instead of having a single dispatch with a larger time step.

To clarify: The crash reported occurs regardless of the speed up button being pressed.

Hmm, I really can't reproduce the issue. The game never crashes randomly like that on my side.

I tried to reproduce it with cargo run --release but it seems that this only happens with debug.
Let me know if there is anything I can provide to get this clarified.

Ok, I was able to reproduce it when running in Debug. I'm working on it now.

I believe I've tracked the origin of the bug.
If I disable the EnforceBoundsSystem, the crashes disappear. Maybe modifying the transform directly causes some parallelism issues.

caitp commented

I fixed this in #83, but #74 might be a better solution