slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
17.54k stars 600 forks source link

Demo app crashes in Windows 11 #1707

Closed teminian closed 1 year ago

teminian commented 2 years ago

Platform: Windows 11(Korean version), Skia, C++ Details: Demo app todo.exe crashes with following steps

  1. Run todo.exe
  2. Input something in "What needs to be done?" LineEdit
  3. Click with mouse or select with keyboard "Add New Entry" button
  4. Press Shift-Tab in keyboard
  5. todo.exe crashes with following message: thread '' panicked at 'byte index 5 is out of bounds of ``', library\core\src\str\mod.rs:107:9
tronical commented 2 years ago

Hi @teminian , I've been trying to reproduce this but haven't had any luck. I've recorded a quick clip of me trying to reproduce the above steps. Are those roughly in line?

This is with a C++ build, the Skia backend, Windows 11.

https://user-images.githubusercontent.com/1486/193770256-2c1d0c14-739a-45fa-bf88-fc59d858f50b.mov

teminian commented 2 years ago

Sorry for the inconvenience. There was confusion about the reproduction of the issue. Focusing must have been done in keyboard only, without any mouse input. So to reproduce:

  1. Run Todo app
  2. Input something in "What Needs to be done?" LineEdit
  3. Press Tab key to move focus to "Add New Entry" button
  4. Press Shift-Tab and the app crashes

Please refer to the link below for app crash(GitHub doesn't allow to upload mkv) https://drive.google.com/open?id=1kdbv49eONL7YvvRghhuopr8_we0JevTf&authuser=teminian%40gmail.com&usp=drive_fs

tronical commented 2 years ago

Thanks for the updated instructions. I'm only using the keyboard, but somehow I still can't reproduce the crash when pressing shift-tab to go back from the "Add New Entry" button to the line edit :(

Could you run yours with RUST_BACKTRACE=full as environment variable set?

teminian commented 2 years ago

Here you go. Hope this helps

thread '<unnamed>' panicked at 'byte index 11 is out of bounds of ``', library\core\src\str\mod.rs:107:9
stack backtrace:
   0:     0x7ffca4102d4f - std::backtrace_rs::backtrace::dbghelp::trace
                               at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library\std\src\..\..\backtrace\src\backtrace\dbghelp.rs:98
   1:     0x7ffca4102d4f - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ffca4102d4f - std::sys_common::backtrace::_print_fmt
                               at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library\std\src\sys_common\backtrace.rs:66
   3:     0x7ffca4102d4f - std::sys_common::backtrace::_print::impl$0::fmt
                               at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library\std\src\sys_common\backtrace.rs:45
   4:     0x7ffca411c61a - core::fmt::write
                               at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library\core\src\fmt\mod.rs:1198
   5:     0x7ffca40fead9 - std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>
                               at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library\std\src\io\mod.rs:1672
   6:     0x7ffca41052fb - std::sys_common::backtrace::_print
                               at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library\std\src\sys_common\backtrace.rs:48
   7:     0x7ffca41052fb - std::sys_common::backtrace::print
                               at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library\std\src\sys_common\backtrace.rs:35
   8:     0x7ffca41052fb - std::panicking::default_hook::closure$1
                               at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library\std\src\panicking.rs:295
   9:     0x7ffca4104f75 - std::panicking::default_hook
                               at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library\std\src\panicking.rs:314
  10:     0x7ffca41058a9 - std::panicking::rust_panic_with_hook
                               at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library\std\src\panicking.rs:698
  11:     0x7ffca41057ad - std::panicking::begin_panic_handler::closure$0
                               at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library\std\src\panicking.rs:588
  12:     0x7ffca41036d7 - std::sys_common::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library\std\src\sys_common\backtrace.rs:138
  13:     0x7ffca4105489 - std::panicking::begin_panic_handler
                               at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library\std\src\panicking.rs:584
  14:     0x7ffca47520d5 - core::panicking::panic_fmt
                               at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library\core\src\panicking.rs:142
  15:     0x7ffca4120788 - core::str::slice_error_fail_rt
                               at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library\core\src\str\mod.rs:107
  16:     0x7ffca4114cd9 - core::ops::function::FnOnce::call_once<never$ (*)(str,usize,usize),tuple$<str,usize,usize> >
                               at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library\core\src\ops\function.rs:248
  17:     0x7ffca411991b - core::intrinsics::const_eval_select<tuple$<str,usize,usize>,never$ (*)(str,usize,usize),never$ (*)(str,usize,usize),never$>
                               at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library\core\src\intrinsics.rs:2696
  18:     0x7ffca47523d2 - core::str::slice_error_fail
                               at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library\core\src\str\mod.rs:86
  19:     0x7ffca3cc8adc - i_slint_backend_winit::renderer::skia::textlayout::cursor_rect::h0041900402a60bdf
  20:     0x7ffca3cd6d7d - <i_slint_backend_winit::renderer::skia::itemrenderer::SkiaRenderer as i_slint_core::item_rendering::ItemRenderer>::draw_text_input::he234d4d45d2a50e1
  21:     0x7ffca3e23a06 - i_slint_core::items::TextInputVTable::render::hdf8ed5d70ff60ee8
  22:     0x7ffca3e31af8 - i_slint_core::item_tree::<impl i_slint_core::item_tree::ItemVisitor_vtable_mod::ItemVisitor for T>::visit_item::hbdfc39c63d5a4343
  23:     0x7ffca3e82e1c - i_slint_core::item_tree::ItemVisitor_vtable_mod::ItemVisitorVTable::new::visit_item::h847961d6037149a9
  24:     0x7ffca3e3b5b9 - i_slint_core::item_tree::<impl i_slint_core::item_tree::ItemVisitor_vtable_mod::ItemVisitor for T>::visit_item::h6656e8e9cbd1d93c
  25:     0x7ffca3e3b6e3 - slint_visit_item_tree
  26:     0x7ff66d801a34 - <unknown>
  27:     0x7ffca3e31b69 - i_slint_core::item_tree::<impl i_slint_core::item_tree::ItemVisitor_vtable_mod::ItemVisitor for T>::visit_item::hbdfc39c63d5a4343
  28:     0x7ffca3e82e1c - i_slint_core::item_tree::ItemVisitor_vtable_mod::ItemVisitorVTable::new::visit_item::h847961d6037149a9
  29:     0x7ffca3e3b5b9 - i_slint_core::item_tree::<impl i_slint_core::item_tree::ItemVisitor_vtable_mod::ItemVisitor for T>::visit_item::h6656e8e9cbd1d93c
  30:     0x7ffca3e3b6e3 - slint_visit_item_tree
  31:     0x7ff66d801a34 - <unknown>
  32:     0x7ffca3e31b69 - i_slint_core::item_tree::<impl i_slint_core::item_tree::ItemVisitor_vtable_mod::ItemVisitor for T>::visit_item::hbdfc39c63d5a4343
  33:     0x7ffca3e82e1c - i_slint_core::item_tree::ItemVisitor_vtable_mod::ItemVisitorVTable::new::visit_item::h847961d6037149a9
  34:     0x7ffca3e3b5b9 - i_slint_core::item_tree::<impl i_slint_core::item_tree::ItemVisitor_vtable_mod::ItemVisitor for T>::visit_item::h6656e8e9cbd1d93c
  35:     0x7ffca3e3b6e3 - slint_visit_item_tree
  36:     0x7ff66d801a34 - <unknown>
  37:     0x7ffca3e31b69 - i_slint_core::item_tree::<impl i_slint_core::item_tree::ItemVisitor_vtable_mod::ItemVisitor for T>::visit_item::hbdfc39c63d5a4343
  38:     0x7ffca3e82e1c - i_slint_core::item_tree::ItemVisitor_vtable_mod::ItemVisitorVTable::new::visit_item::h847961d6037149a9
  39:     0x7ffca3e3b5b9 - i_slint_core::item_tree::<impl i_slint_core::item_tree::ItemVisitor_vtable_mod::ItemVisitor for T>::visit_item::h6656e8e9cbd1d93c
  40:     0x7ffca3e3b6e3 - slint_visit_item_tree
  41:     0x7ff66d801a34 - <unknown>
  42:     0x7ffca3e31b69 - i_slint_core::item_tree::<impl i_slint_core::item_tree::ItemVisitor_vtable_mod::ItemVisitor for T>::visit_item::hbdfc39c63d5a4343
  43:     0x7ffca3e82e1c - i_slint_core::item_tree::ItemVisitor_vtable_mod::ItemVisitorVTable::new::visit_item::h847961d6037149a9
  44:     0x7ffca3e3b5b9 - i_slint_core::item_tree::<impl i_slint_core::item_tree::ItemVisitor_vtable_mod::ItemVisitor for T>::visit_item::h6656e8e9cbd1d93c
  45:     0x7ffca3e3b6e3 - slint_visit_item_tree
  46:     0x7ff66d801a34 - <unknown>
  47:     0x7ffca3e31b69 - i_slint_core::item_tree::<impl i_slint_core::item_tree::ItemVisitor_vtable_mod::ItemVisitor for T>::visit_item::hbdfc39c63d5a4343
  48:     0x7ffca3e82e1c - i_slint_core::item_tree::ItemVisitor_vtable_mod::ItemVisitorVTable::new::visit_item::h847961d6037149a9
  49:     0x7ffca3e3b5b9 - i_slint_core::item_tree::<impl i_slint_core::item_tree::ItemVisitor_vtable_mod::ItemVisitor for T>::visit_item::h6656e8e9cbd1d93c
  50:     0x7ffca3e3b709 - slint_visit_item_tree
  51:     0x7ff66d801a34 - <unknown>
  52:     0x7ffca3e31708 - i_slint_core::item_rendering::render_component_items::hf8e7932c1208dc25
  53:     0x7ffca3cb7fde - <i_slint_backend_winit::renderer::skia::itemrenderer::SkiaRenderer as i_slint_core::item_rendering::ItemRenderer>::draw_cached_pixmap::{{closure}}::{{closure}}::h9cec6474cf94fa10
  54:     0x7ffca3cb68ee - i_slint_core::properties::PropertyTracker<DirtyHandler>::evaluate_as_dependency_root::h4fcc478aefb45dc6
  55:     0x7ffca3cb078b - <i_slint_backend_winit::renderer::skia::d3d_surface::D3DSurface as i_slint_backend_winit::renderer::skia::Surface>::render::hf7782e63d1c35602
  56:     0x7ffca3ca9a26 - i_slint_backend_winit::glwindow::icon_to_winit::h2802d56b27beb53f
  57:     0x7ffca3cbee01 - i_slint_backend_winit::event_loop::CURRENT_WINDOW_TARGET::<impl i_slint_backend_winit::event_loop::CURRENT_WINDOW_TARGET>::set::h9d35d2aad8448779
  58:     0x7ffca3ccfe53 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h36cdcd2203bc12ef
  59:     0x7ffca3cc07bb - <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::he31cb1c44ee6d510
  60:     0x7ffca3cd134c - winit::platform_impl::platform::event_loop::runner::EventLoopRunner<T>::register_window::hb208eeecbb42f550
  61:     0x7ffca3cd0020 - winit::platform_impl::platform::event_loop::runner::EventLoopRunner<T>::send_event::h572449020212c06f
  62:     0x7ffca3cc2668 - winit::platform_impl::platform::event_loop::public_window_callback_inner::{{closure}}::h292b837878c3603d
  63:     0x7ffca3cd0566 - winit::platform_impl::platform::event_loop::runner::EventLoopRunner<T>::catch_unwind::hccd17eeba6ac8611
  64:     0x7ffca3cb2341 - winit::platform_impl::platform::event_loop::public_window_callback::hf2608f441c42f980
  65:     0x7ffd362be9bc - DispatchMessageW
  66:     0x7ffd362be5dc - DispatchMessageW
  67:     0x7ffd362d1e2d - MapWindowPoints
  68:     0x7ffd37692db4 - KiUserCallbackDispatcher
  69:     0x7ffd35221ad4 - NtUserDispatchMessage
  70:     0x7ffd362be4c4 - DispatchMessageW
  71:     0x7ffca3cb1ba7 - winit::platform_impl::platform::event_loop::EventLoop<T>::run_return::h72a366a522009209
  72:     0x7ffca3cbdd9b - i_slint_backend_winit::event_loop::run::hfe42d29408748ca2
  73:     0x7ff66d819e96 - <unknown>
  74:     0x7ff66d81a73c - <unknown>
  75:     0x7ffd35ed244d - BaseThreadInitThunk
  76:     0x7ffd3764df78 - RtlUserThreadStart
tronical commented 2 years ago

Thanks, this helps a little. I can see where this happens, but I can't reproduce it still :(. One detail I'm noticing in the video clip: After the "Add New Entry" button is focused, you're writing that you're pressing "Shift-Tab". For me that moves the focus back to the line edit. But in your video clip it appears that the "Hello" item gets added to the todo list. Did you also press "Enter" before pressing "Shift-Tab" perhaps? Or did "Shift-Tab" add the item to the list and move the focus back to the line edit?

teminian commented 2 years ago

That's right. After focus is move via Tab key I pressed Enter or Space to add "Hello" to todo list. So, summarizing keystroke:

  1. Tab - Hello - Shift Tab: OK
  2. Tab - Hello - either Space Bar or Enter - Shift Tab: crash

After pressing Space Bar or Enter key, the keyboard focus disappears. And if I press Shift-Tab in that timing the app crashes. I think this is related with some kind of dangling pointer(or index out of bound)?

tronical commented 2 years ago

@teminian Today Olivier found a way to reproduce a similar issue that ma have a similar root cause as this issue. I’ve merged https://github.com/slint-ui/slint/pull/1786 to master to address this. Could you check if that also fixes the issue you see? (At a later point in time, at your convenience:)

ogoffart commented 1 year ago

Closing this issue for now as it should be fixed. Please re-open or comment if it is not fixed.