Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

called Option::unwrap() on a None value - Event::KeyUp #36

Closed
kolen opened this issue Apr 8, 2019 · 3 comments
Closed

called Option::unwrap() on a None value - Event::KeyUp #36

kolen opened this issue Apr 8, 2019 · 3 comments

Comments

@kolen
Copy link
Contributor

kolen commented Apr 8, 2019

  • version from master branch (dd40dc4)
  • Mac OS 10.13.6

It crashes after starting and typing few characters (probably even after first keypress)

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:345:21
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: std::panicking::continue_panic_fmt
             at src/libstd/panicking.rs:385
   6: std::panicking::try::do_call
             at src/libstd/panicking.rs:312
   7: core::char::methods::<impl char>::escape_debug
             at src/libcore/panicking.rs:85
   8: core::char::methods::<impl char>::escape_debug
             at src/libcore/panicking.rs:49
   9: sdl2::keyboard::Mod::from_bits
             at /rustc/2aa4c46cfdd726e97360c2734835aa3515e8c858/src/libcore/macros.rs:10
  10: sdl2::event::WindowEventId::from_ll
             at /Users/kolen/.cargo/registry/src/github.com-1ecc6299db9ec823/sdl2-0.21.0/src/sdl2/event.rs:811
  11: sdl2::event::poll_event
             at /Users/kolen/.cargo/registry/src/github.com-1ecc6299db9ec823/sdl2-0.21.0/src/sdl2/event.rs:1173
  12: <alloc::borrow::Cow<'a, str> as alloc::string::ToString>::to_string
             at /Users/kolen/.cargo/registry/src/github.com-1ecc6299db9ec823/sdl2-0.21.0/src/sdl2/event.rs:1219
  13: <rustzx::app::events::events_sdl::EventsSdl as rustzx::app::events::EventDevice>::pop_event
             at src/app/events/events_sdl.rs:113
  14: rustzx::app::rustzx::RustzxApp::start
             at src/app/rustzx.rs:109
  15: rustzx::main
             at src/main.rs:54
  16: std::rt::lang_start::{{closure}}
             at /rustc/2aa4c46cfdd726e97360c2734835aa3515e8c858/src/libstd/rt.rs:64
  17: std::panicking::try::do_call
             at src/libstd/rt.rs:49
             at src/libstd/panicking.rs:297
  18: panic_unwind::dwarf::eh::read_encoded_pointer
             at src/libpanic_unwind/lib.rs:92
  19: <std::panicking::begin_panic::PanicPayload<A> as core::panic::BoxMeUp>::get
             at src/libstd/panicking.rs:276
             at src/libstd/panic.rs:388
             at src/libstd/rt.rs:48
  20: std::rt::lang_start
             at /rustc/2aa4c46cfdd726e97360c2734835aa3515e8c858/src/libstd/rt.rs:64
  21: rustzx::main

Unwrap occurs in sdl2/event.rs in sdl2 crate.

                    keymod: keyboard::Mod::from_bits(event.keysym._mod as SDL_Keymod).unwrap(),

It does not occur in branch with latest version of sdl2. Probably fixed by this PR in sdl2: Rust-SDL2/rust-sdl2#780

@kolen
Copy link
Contributor Author

kolen commented Apr 10, 2019

Figured out that it's unrelated to Rust-SDL2/rust-sdl2#780, "safe unwrap" was added here only for keydown, not keyup. It was fixed in some other commit in sdl2, probably related to C wrapping and struct alignment.

@pacmancoder
Copy link
Collaborator

@kolen
I think this issue can be closed after merge of the latest sdl2?

@kolen
Copy link
Contributor Author

kolen commented Aug 14, 2019

Yes, it was happening in sdl2::keyboard::Mod::from_bits and no longer occurs with newer sdl2.

@kolen kolen closed this as completed Aug 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants