dimooper icon indicating copy to clipboard operation
dimooper copied to clipboard

Any keyboard action crashes the app on latest Rust

Open rexim opened this issue 6 years ago • 2 comments

  • Caused by #213
  • Blocked by #238

Steps to reproduce

  • Setup the latest Rust (nightly or stable) in default.nix
  • $ nix-shell
  • $ cargo build
  • $ cargo run <ports...>
  • Focus on the app window
  • Press any key

Observed behaviour

The app crashed with the following error:

Listening on: 3 Launchkey Mini MIDI 1
Sending recorded events: 7 Synth input port (18189:0)
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /checkout/src/libcore/option.rs:335:20
note: Run with `RUST_BACKTRACE=1` for a backtrace.

The stracktrace with RUST_BACKTRACE=1


Listening on: 3 Launchkey Mini MIDI 1
Sending recorded events: 7 Synth input port (18189:0)
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /checkout/src/libcore/option.rs:335:20
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
   1: std::sys_common::backtrace::_print
   2: std::panicking::default_hook::{{closure}}
   3: std::panicking::default_hook
   4: std::panicking::rust_panic_with_hook
   5: std::panicking::begin_panic_new
   6: std::panicking::begin_panic_fmt
   7: rust_begin_unwind
   8: core::panicking::panic_fmt
   9: core::panicking::panic
  10: <core::option::Option<T>>::unwrap
             at /checkout/src/libcore/macros.rs:22
  11: sdl2::event::Event::from_ll
             at /home/rexim/.cargo/registry/src/github.com-1ecc6299db9ec823/sdl2-0.21.0/src/sdl2/event.rs:799
  12: sdl2::event::poll_event
             at /home/rexim/.cargo/registry/src/github.com-1ecc6299db9ec823/sdl2-0.21.0/src/sdl2/event.rs:1173
  13: <sdl2::event::EventPollIterator<'a> as core::iter::iterator::Iterator>::next
             at /home/rexim/.cargo/registry/src/github.com-1ecc6299db9ec823/sdl2-0.21.0/src/sdl2/event.rs:1294
  14: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
             at /checkout/src/liballoc/vec.rs:1782
  15: <alloc::vec::Vec<T> as core::iter::traits::FromIterator<T>>::from_iter
             at /checkout/src/liballoc/vec.rs:1695
  16: core::iter::iterator::Iterator::collect
             at /checkout/src/libcore/iter/iterator.rs:1303
  17: dimooper::screen::event_loop::EventLoop::run
             at src/screen/event_loop.rs:41
  18: dimooper::main
             at src/main.rs:105
  19: __rust_maybe_catch_panic
  20: std::rt::lang_start
  21: main
  22: __libc_start_main
  23: _start
             at ../sysdeps/x86_64/start.S:120

Expected behaviour

Application doesn't crash and continues to work correctly.

rexim avatar Jul 18 '17 10:07 rexim

Missing #[repr(C)] that was fixed in AngryLawyer/rust-sdl2@5a32976 is the reason of 'crash'. It is revealed only after update of rustc most likely because of field reordering optimization in 1.18.

0xd34d10cc avatar Jul 28 '17 20:07 0xd34d10cc

@0xd34d10cc Thanks for sharing this information! I'd be happy to upgrade the SDL bindings, but the recent version causes the following error https://travis-ci.org/tsoding/dimooper/builds/257238425#L1117

Basically, SDL on Travis is so old (2.0.0) it doesn't have SDL_GetDisplayDPI which was introduced in 2.0.4. So we have to use bindings that do not refer to that function.

I'll create a separate issue for the SDL upgrade.

rexim avatar Jul 29 '17 05:07 rexim