Open nicolaiunrein opened 4 months ago
Unfortunately I don't have the time to create a minimal reproducable example but wanted you know anyway.
I am unable to reproduce this with rust 1.78, please take some time to make a minimal repro so we can fix this asap
No repro but seems like I ran into a similar one related to Rust 1.78:
thread 'tokio-runtime-worker' panicked at library\core\src\panicking.rs:156:5:
unsafe precondition(s) violated: slice::from_raw_parts requires the pointer to be aligned and non-null, and the total size of the slice not to exceed `isize::MAX`
Workaround:
RUSTFLAGS='-C debug_assertions=no' npm run tauri build -- --debug
tauri info
[✔] Environment
- OS: Windows 10.0.19045 X64
✔ WebView2: 125.0.2535.92
✔ MSVC: Visual Studio Build Tools 2019
✔ rustc: 1.78.0 (9b00956e5 2024-04-29)
✔ cargo: 1.78.0 (54d8815d0 2024-03-26)
✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
- node: 20.14.0
- yarn: 1.22.4
- npm: 8.4.0
[-] Packages
- tauri [RUST]: 1.5.3
- tauri-build [RUST]: 1.5.0
- wry [RUST]: 0.24.6
- tao [RUST]: 0.16.5
- @tauri-apps/api : not installed!
- @tauri-apps/cli [NPM]: 1.5.14
[-] App
- build-type: bundle
- CSP: default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'
- distDir: ../ui/build
- devPath: http://localhost:5173/
UPDATE: Not recommending the workaround anymore, it can interfere with code that's trying to test whether we're in debug mode or not.
@betamos Did you capture a backtrace? It seems the issue you are seeing is caused by a different assertion. I figured out mine is caused by moving the above struct (with an internal Rc) to a different thread which is UB because Rc is not Send and dropping it there. The assertion I hit is that the strong count does not equal 0 which IMO can only happen in unsafe code. The question is how to re-create a situation where the Rc can escape the thread it was created on. I have some vague ideas but need to find the time to investigate. In summary we are calling a method with a callback closure (FnMut) where we reference a Box<dyn Eventemitter>
(a trait object around a tauri::Window` if I remember correctly) from inside the closure.
I reproduced the error.
thread 'thread 'maintokio-runtime-worker' panicked at ' panicked at library\core\src\panicking.rslibrary\core\src\panicking.rs::221221::55:
:
unsafe precondition(s) violated: hint::assert_unchecked must never be called when the condition is falseunsafe precondition(s) violated: hint::assert_unchecked must never be called when the condition is false
stack backtrace:
0: 0x7ff6ea1fb78d - std::backtrace_rs::backtrace::dbghelp64::trace
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da/library\std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:91
1: 0x7ff6ea1fb78d - std::backtrace_rs::backtrace::trace_unsynchronized
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
2: 0x7ff6ea1fb78d - std::sys_common::backtrace::_print_fmt
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da/library\std\src\sys_common\backtrace.rs:68
3: 0x7ff6ea1fb78d - std::sys_common::backtrace::_print::impl$0::fmt
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da/library\std\src\sys_common\backtrace.rs:44
4: 0x7ff6ea2215f9 - core::fmt::rt::Argument::fmt
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da/library\core\src\fmt\rt.rs:165
5: 0x7ff6ea2215f9 - core::fmt::write
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da/library\core\src\fmt\mod.rs:1168
6: 0x7ff6ea1f65a1 - std::io::Write::write_fmt<std::sys::pal::windows::stdio::Stderr>
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da/library\std\src\io\mod.rs:1835
7: 0x7ff6ea1fb566 - std::sys_common::backtrace::print
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da/library\std\src\sys_common\backtrace.rs:34
8: 0x7ff6ea1fd9a8 - std::panicking::default_hook::closure$1
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da/library\std\src\panicking.rs:265
9: 0x7ff6ea1fd659 - std::panicking::default_hook
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da/library\std\src\panicking.rs:292
10: 0x7ff6ea1fdfde - std::panicking::rust_panic_with_hook
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da/library\std\src\panicking.rs:793
11: 0x7ff6ea1fddef - std::panicking::begin_panic_handler::closure$0
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da/library\std\src\panicking.rs:660
12: 0x7ff6ea1fc0ff - std::sys_common::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da/library\std\src\sys_common\backtrace.rs:171
13: 0x7ff6ea1fda46 - std::panicking::begin_panic_handler
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da/library\std\src\panicking.rs:658
14: 0x7ff6ea386add - core::panicking::panic_nounwind_fmt::runtime
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da/library\core\src\panicking.rs:112
15: 0x7ff6ea386add - core::panicking::panic_nounwind_fmt
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da/library\core\src\panicking.rs:122
16: 0x7ff6ea386b83 - core::panicking::panic_nounwind
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da/library\core\src\panicking.rs:221
17: 0x7ff6e9711512 - core::hint::assert_unchecked::precondition_check
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da\library\core\src\ub_checks.rs:68
18: 0x7ff6e9764ee6 - alloc::rc::RcInnerPtr::inc_strong<alloc::rc::RcBox<std::sync::mutex::Mutex<tao::global_shortcut::ShortcutManager> > >
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da\library\alloc\src\rc.rs:3403
19: 0x7ff6e976b015 - alloc::rc::impl$29::clone<std::sync::mutex::Mutex<tao::global_shortcut::ShortcutManager>,alloc::alloc::Global>
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da\library\alloc\src\rc.rs:2227
20: 0x7ff6e92d6346 - tauri_runtime_wry::impl$49::run::closure$0<enum2$<tauri::EventLoopMessage>,tauri::app::impl$18::run::closure_env$0<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> >,tauri::app::impl$19::run::closure_env$0<tauri_runtime_wry::Wry<enum2$<tauri::EventLo
at C:\Users\SIN\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tauri-runtime-wry-0.14.8\src\lib.rs:2334
21: 0x7ff6e928530c - tao::platform_impl::platform::event_loop::impl$2::run_return::closure$0<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > >,tauri_runtime_wry::impl$49::run::closure_env$0<enum2$<tauri::EventLoopMessage>,tauri::app::impl$18::run::closure_e
at C:\Users\SIN\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tao-0.16.9\src\platform_impl\windows\event_loop.rs:234
22: 0x7ff6e9641245 - alloc::boxed::impl$49::call_mut<tuple$<enum2$<tao::event::Event<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > > >,ref_mut$<enum2$<tao::event_loop::ControlFlow> > >,dyn$<core::ops::function::FnMut<tuple$<enum2$<tao::event::Event<enum
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da\library\alloc\src\boxed.rs:2069
23: 0x7ff6e975f234 - tao::platform_impl::platform::event_loop::runner::impl$3::call_event_handler::closure$0<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >
at C:\Users\SIN\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tao-0.16.9\src\platform_impl\windows\event_loop\runner.rs:250
24: 0x7ff6e97aa544 - core::panic::unwind_safe::impl$25::call_once<tuple$<>,tao::platform_impl::platform::event_loop::runner::impl$3::call_event_handler::closure_env$0<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > > >
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da\library\core\src\panic\unwind_safe.rs:272
25: 0x7ff6e973ed04 - std::panicking::try::do_call<core::panic::unwind_safe::AssertUnwindSafe<tao::platform_impl::platform::event_loop::runner::impl$3::call_event_handler::closure_env$0<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > > >,tuple$<> >
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da\library\std\src\panicking.rs:553
26: 0x7ff6e9752243 - tauri::endpoints::_::impl$0::deserialize::impl$3::expecting
27: 0x7ff6e973daba - std::panicking::try<tuple$<>,core::panic::unwind_safe::AssertUnwindSafe<tao::platform_impl::platform::event_loop::runner::impl$3::call_event_handler::closure_env$0<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > > > >
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da\library\std\src\panicking.rs:517
28: 0x7ff6e96e5c09 - std::panic::catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<tao::platform_impl::platform::event_loop::runner::impl$3::call_event_handler::closure_env$0<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > > >,tuple$<> >
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da\library\std\src\panic.rs:350
29: 0x7ff6e975d235 - tao::platform_impl::platform::event_loop::runner::EventLoopRunner<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >::catch_unwind<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > >,tuple$<>,tao::platform_impl::platf
at C:\Users\SIN\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tao-0.16.9\src\platform_impl\windows\event_loop\runner.rs:156
30: 0x7ff6e975ef5b - tao::platform_impl::platform::event_loop::runner::EventLoopRunner<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >::call_event_handler<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >
at C:\Users\SIN\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tao-0.16.9\src\platform_impl\windows\event_loop\runner.rs:242
31: 0x7ff6e975cf86 - tao::platform_impl::platform::event_loop::runner::EventLoopRunner<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >::send_event<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >
at C:\Users\SIN\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tao-0.16.9\src\platform_impl\windows\event_loop\runner.rs:224
32: 0x7ff6e92864d3 - tao::platform_impl::platform::event_loop::ThreadMsgTargetSubclassInput<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >::send_event<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >
at C:\Users\SIN\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tao-0.16.9\src\platform_impl\windows\event_loop.rs:127
33: 0x7ff6e928630c - tao::platform_impl::platform::event_loop::thread_event_target_callback::closure$0<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >
at C:\Users\SIN\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tao-0.16.9\src\platform_impl\windows\event_loop.rs:2226
34: 0x7ff6e935d377 - core::ops::function::FnOnce::call_once<tao::platform_impl::platform::event_loop::thread_event_target_callback::closure_env$0<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >,tuple$<> >
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da\library\core\src\ops\function.rs:250
35: 0x7ff6e8fd1351 - core::panic::unwind_safe::impl$25::call_once<windows::Windows::Win32::Foundation::LRESULT,tao::platform_impl::platform::event_loop::thread_event_target_callback::closure_env$0<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > > >
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da\library\core\src\panic\unwind_safe.rs:272
36: 0x7ff6e93075fd - std::panicking::try::do_call<core::panic::unwind_safe::AssertUnwindSafe<tao::platform_impl::platform::event_loop::thread_event_target_callback::closure_env$0<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > > >,windows::Windows::Win32:
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da\library\std\src\panicking.rs:553
37: 0x7ff6e930ec73 - std::panicking::try::do_catch<core::panic::unwind_safe::AssertUnwindSafe<tokio::runtime::task::harness::poll_future::closure_env$0<enum2$<tauri::endpoints::shell::impl$0::execute::async_block_env$1<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> > >
38: 0x7ff6e9302c7b - std::panicking::try<windows::Windows::Win32::Foundation::LRESULT,core::panic::unwind_safe::AssertUnwindSafe<tao::platform_impl::platform::event_loop::thread_event_target_callback::closure_env$0<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessa
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da\library\std\src\panicking.rs:517
39: 0x7ff6e9062441 - std::panic::catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<tao::platform_impl::platform::event_loop::thread_event_target_callback::closure_env$0<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > > >,windows::Windows::Win32::Fou
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da\library\std\src\panic.rs:350
40: 0x7ff6e92bd422 - tao::platform_impl::platform::event_loop::runner::EventLoopRunner<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >::catch_unwind<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > >,windows::Windows::Win32::Foundatio
at C:\Users\SIN\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tao-0.16.9\src\platform_impl\windows\event_loop\runner.rs:156
41: 0x7ff6e9285909 - tao::platform_impl::platform::event_loop::thread_event_target_callback<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >
at C:\Users\SIN\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tao-0.16.9\src\platform_impl\windows\event_loop.rs:2275
42: 0x7ffdcaa08252 - DefSubclassProc
43: 0x7ffdcaa08037 - DSA_InsertItem
44: 0x7ffdda3089a1 - DispatchMessageW
45: 0x7ffdda308461 - DispatchMessageW
46: 0x7ff6e93828af - windows::Windows::Win32::UI::WindowsAndMessaging::DispatchMessageW
at C:\Users\SIN\.cargo\registry\src\index.crates.io-6f17d22bba15001f\windows-0.39.0\src\Windows\Win32\UI\WindowsAndMessaging\mod.rs:2671
47: 0x7ff6e9284f93 - tao::platform_impl::platform::event_loop::EventLoop<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >::run_return<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > >,tauri_runtime_wry::impl$49::run::closure_env$0<enu
at C:\Users\SIN\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tao-0.16.9\src\platform_impl\windows\event_loop.rs:264
48: 0x7ff6e928565b - tao::platform_impl::platform::event_loop::EventLoop<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >::run<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > >,tauri_runtime_wry::impl$49::run::closure_env$0<enum2$<tau
at C:\Users\SIN\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tao-0.16.9\src\platform_impl\windows\event_loop.rs:218
49: 0x7ff6e91c1a68 - tao::event_loop::EventLoop<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >::run<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > >,tauri_runtime_wry::impl$49::run::closure_env$0<enum2$<tauri::EventLoopMessage>,tau
at C:\Users\SIN\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tao-0.16.9\src\event_loop.rs:179
50: 0x7ff6e92d5ef4 - tauri_runtime_wry::impl$49::run<enum2$<tauri::EventLoopMessage>,tauri::app::impl$18::run::closure_env$0<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> >,tauri::app::impl$19::run::closure_env$0<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage>
at C:\Users\SIN\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tauri-runtime-wry-0.14.8\src\lib.rs:2299
51: 0x7ff6e918dfe2 - tauri::app::App<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> > >::run<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> >,tauri::app::impl$19::run::closure_env$0<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> >,tauri_utils::assets::E
at C:\Users\SIN\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tauri-1.6.8\src\app.rs:868
52: 0x7ff6e918e3bc - tauri::app::Builder<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> > >::run<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> >,tauri_utils::assets::EmbeddedAssets>
at C:\Users\SIN\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tauri-1.6.8\src\app.rs:1727
53: 0x7ff6e92e1243 - ostring::main::async_block$0
at D:\Pro\Pro_Melzer\Code_Tauri\MelzerScreen\src-tauri\src\main.rs:66
54: 0x7ff6e9185739 - tokio::runtime::park::impl$4::block_on::closure$0<enum2$<ostring::main::async_block_env$0> >
at C:\Users\SIN\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tokio-1.38.0\src\runtime\park.rs:281
55: 0x7ff6e918554e - tokio::runtime::coop::with_budget
at C:\Users\SIN\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tokio-1.38.0\src\runtime\coop.rs:107
56: 0x7ff6e918554e - tokio::runtime::coop::budget
at C:\Users\SIN\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tokio-1.38.0\src\runtime\coop.rs:73
57: 0x7ff6e918554e - tokio::runtime::park::CachedParkThread::block_on<enum2$<ostring::main::async_block_env$0> >
at C:\Users\SIN\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tokio-1.38.0\src\runtime\park.rs:281
58: 0x7ff6e92ed8e6 - tokio::runtime::context::blocking::BlockingRegionGuard::block_on<enum2$<ostring::main::async_block_env$0> >
at C:\Users\SIN\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tokio-1.38.0\src\runtime\context\blocking.rs:66
59: 0x7ff6e931f0f9 - tokio::runtime::scheduler::multi_thread::impl$0::block_on::closure$0<enum2$<ostring::main::async_block_env$0> >
at C:\Users\SIN\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tokio-1.38.0\src\runtime\scheduler\multi_thread\mod.rs:87
60: 0x7ff6e90b2a1d - tokio::runtime::context::runtime::enter_runtime<tokio::runtime::scheduler::multi_thread::impl$0::block_on::closure_env$0<enum2$<ostring::main::async_block_env$0> >,tuple$<> >
at C:\Users\SIN\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tokio-1.38.0\src\runtime\context\runtime.rs:65
61: 0x7ff6e931f0b4 - tokio::runtime::scheduler::multi_thread::MultiThread::block_on<enum2$<ostring::main::async_block_env$0> >
at C:\Users\SIN\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tokio-1.38.0\src\runtime\scheduler\multi_thread\mod.rs:86
62: 0x7ff6e90f64bd - tokio::runtime::runtime::Runtime::block_on<enum2$<ostring::main::async_block_env$0> >
at C:\Users\SIN\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tokio-1.38.0\src\runtime\runtime.rs:349
63: 0x7ff6e91925d0 - ostring::main
at D:\Pro\Pro_Melzer\Code_Tauri\MelzerScreen\src-tauri\src\main.rs:66
64: 0x7ff6e935db1b - core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da\library\core\src\ops\function.rs:250
65: 0x7ff6e9005f1e - core::hint::black_box
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da\library\core\src\hint.rs:338
66: 0x7ff6e9005f1e - std::sys_common::backtrace::__rust_begin_short_backtrace<void (*)(),tuple$<> >
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da\library\std\src\sys_common\backtrace.rs:155
67: 0x7ff6e91b5e21 - std::rt::lang_start::closure$0<tuple$<> >
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da\library\std\src\rt.rs:159
68: 0x7ff6ea1efa4e - std::rt::lang_start_internal
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da/library\std\src\rt.rs:141
69: 0x7ff6e91b5dfa - std::rt::lang_start<tuple$<> >
at /rustc/f8e566053207b4ecbcbc7a7d6ded82c43061e3da\library\std\src\rt.rs:158
70: 0x7ff6e91926a9 - main
71: 0x7ff6ea383c6c - invoke_main
at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
72: 0x7ff6ea383c6c - __scrt_common_main_seh
at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
73: 0x7ffdda72257d - BaseThreadInitThunk
74: 0x7ffddc54af28 - RtlUserThreadStart
thread caused non-unwinding panic. aborting.
I suspected that the problem was with the emit function, so I executed the following code, and it replicated the problem
loop {
trans_tx.clone().send(TagPayload::default()).await.unwrap();
tokio::time::sleep(Duration::from_millis(10)).await;
if let Ok(data) = trans_rx.try_recv() {
for _ in 0..10 {
if let Result::Ok(_) = app_handle.clone().emit_all("tags_receive", data.clone()) {}
}
} else {
tokio::time::sleep(Duration::from_millis(100)).await;
}
}
tauri info
[✔] Environment
- OS: Windows 10.0.22631 X64
✔ WebView2: 125.0.2535.92
✔ MSVC: Visual Studio ���ɹ��� 2022
✔ rustc: 1.81.0-nightly (f8e566053 2024-06-14)
✔ cargo: 1.81.0-nightly (4dcbca118 2024-06-11)
✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
✔ Rust toolchain: nightly-x86_64-pc-windows-msvc (environment override by RUSTUP_TOOLCHAIN)
- node: 20.12.2
- pnpm: 8.15.6
- npm: 10.8.0
- bun: 1.1.10
[-] Packages
- tauri [RUST]: 1.6.8
- tauri-build [RUST]: 1.5.2
- wry [RUST]: 0.24.10
- tao [RUST]: 0.16.9
- tauri-cli [RUST]: 1.5.14
- @tauri-apps/api [NPM]: 1.5.6
- @tauri-apps/cli [NPM]: 1.5.14
[-] App
- build-type: bundle
- CSP: unset
- distDir: ../dist
- devPath: http://localhost:1420/
- framework: Vue.js
- bundler: Vite
When I adjusted the number of repetitions downward, the error reported became a WebViewc error.
code:
loop {
trans_tx.clone().send(TagPayload::default()).await.unwrap();
tokio::time::sleep(Duration::from_millis(10)).await;
if let Ok(data) = trans_rx.try_recv() {
for _ in 0..2 {
if let Result::Ok(_) = app_handle.clone().emit_all("tags_receive", data.clone()) {}
}
} else {
tokio::time::sleep(Duration::from_millis(100)).await;
}
}
error:
WebView2 error: WindowsError(Error { code: 0x8007139F, message: 组或资源的状态不是执行请求操作的正确状态。 })
WebView2 error: WindowsError(Error { code: 0x8007139F, message: 组或资源的状态不是执行请求操作的正确状态。 })
WebView2 error: WindowsError(Error { code: 0x8007139F, message: 组或资源的状态不是执行请求操作的正确状态。 })
I must admit I don't really understand why this is happening, both stack traces you posted (though the panic happens in different branches) are crashing bc of an rc increment from a different thread, which, should not really ever happen I don't think? Unless webview2 started delivering events to random threads within the threadpool
I tried but didn't get a proper backtrace for some reason, sorry. Can confirm I'm also using emit, quite a lot.
I tried but didn't get a proper backtrace for some reason, sorry. Can confirm I'm also using emit, quite a lot.
maybe is I emit in setup?
#[tokio::main]
async fn main() {
println!("RUST_BACKTRACE: {:?}", std::env::var("RUST_BACKTRACE"));
tauri::Builder::default()
.setup(move |app| {
let app_handle = app.handle();
tokio::spawn(async move {
app_auth::license_request_listen(app_handle.clone());
app_gw_tauri::muhlbauer_core(app_handle.clone()).await; //emit here!!!!!!!!!!!!!!!!!!!!!!!
});
Ok(())
})
.invoke_handler(tauri::generate_handler![
app_gw_tauri::list_com_cmd,
app_auth::verify_lic_cmd,
app_base::select_folder_cmd,
app_gw_tauri::get_conf_cmd,
app_gw_tauri::set_conf_cmd,
app_gw_tauri::r2k_test_cmd,
app_base::get_sys_info_cmd,
app_base::set_autolaunch_cmd
])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
I must admit I don't really understand why this is happening, both stack traces you posted (though the panic happens in different branches) are crashing bc of an rc increment from a different thread, which, should not really ever happen I don't think? Unless webview2 started delivering events to random threads within the threadpool
And now I Test the emit with sleep(), this panic no happen again
loop {
// .......
trans_tx.clone().send(TagPayload::default()).await.unwrap();
tokio::time::sleep(Duration::from_millis(1)).await;
if let Ok(data) = trans_rx.try_recv() {
if let Result::Ok(_) = app_handle.clone().emit_all("tags_receive", data.clone()) {
tokio::time::sleep(Duration::from_millis(5)).await; // very stable
}
} else {
tokio::time::sleep(Duration::from_millis(100)).await;
}
}
maybe is I emit in setup?
To be clear the code you're showing is not from the setup closure, but a task spawned from it.
But no, for me it's not in setup but from window event handlers (some irrelevant details omitted):
let mut app = tauri::Builder::default()
.invoke_handler(tauri::generate_handler![
get_clipboard_files,
config::set_background,
config::get_config
])
.setup(|app| {
let window_builder =
WindowBuilder::new(app, "main", tauri::WindowUrl::App("index.html".into()));
let window = window_builder.build().unwrap();
let app_handle = app.handle();
let app_handle_2 = app_handle.clone();
window.listen("ui", move |e| {
app_handle_2
.state::<agent::Input>()
.send(e.payload().unwrap())
.expect("channel failure");
});
window.once("init", move |_| {
// Read program output
tauri::async_runtime::spawn(async move {
let agent_result = output
.run()
.try_for_each(|str| async {
app_handle
.emit_to("main", "agent", str)
.map_err(|err| anyhow!("error emitting to window: {:?}", err))
})
.await;
if let Err(ref err) = agent_result {
_ = app_handle.emit_to("main", "agent", agent::EXIT_MSG);
eprintln!("pld failed: {:?}", err);
} else {
eprintln!("pld complete");
}
});
});
Ok(())
})
.on_window_event(move |win_e| { ... })
.menu(menu::get_menu(&ctx.package_info().name))
.on_menu_event(|e| {
eprintln!("menu event: {:?}", e);
})
.build(ctx)
.expect("error while running tauri application");
maybe is I emit in setup?
To be clear the code you're showing is not from the setup closure, but a task spawned from it.
But no, for me it's not in setup but from window event handlers (some irrelevant details omitted):
let mut app = tauri::Builder::default() .invoke_handler(tauri::generate_handler![ get_clipboard_files, config::set_background, config::get_config ]) .setup(|app| { let window_builder = WindowBuilder::new(app, "main", tauri::WindowUrl::App("index.html".into())); let window = window_builder.build().unwrap(); let app_handle = app.handle(); let app_handle_2 = app_handle.clone(); window.listen("ui", move |e| { app_handle_2 .state::<agent::Input>() .send(e.payload().unwrap()) .expect("channel failure"); }); window.once("init", move |_| { // Read program output tauri::async_runtime::spawn(async move { let agent_result = output .run() .try_for_each(|str| async { app_handle .emit_to("main", "agent", str) .map_err(|err| anyhow!("error emitting to window: {:?}", err)) }) .await; if let Err(ref err) = agent_result { _ = app_handle.emit_to("main", "agent", agent::EXIT_MSG); eprintln!("pld failed: {:?}", err); } else { eprintln!("pld complete"); } }); }); Ok(()) }) .on_window_event(move |win_e| { ... }) .menu(menu::get_menu(&ctx.package_info().name)) .on_menu_event(|e| { eprintln!("menu event: {:?}", e); }) .build(ctx) .expect("error while running tauri application");
Thanks! So do I need to change the way I write my code.Is that more reasonable?
Started getting the same issue (I think). I'll be honest, rust scares me so I have no clue what any of this means but I'm here to help solve it asap. This is for an app that I am releasing in 2 weeks so the timing is very rough. I recently upgraded rust and some dependencies to latest versions, and don't remember this happening before that in the last 2 months of development. It will crash my app at random, sometimes 20 seconds after launch, sometimes 10 minutes, and anywhere inbetween. I haven't detected one single action I'm taking that does it.
thread 'main' panicked at library\core\src\panicking.rs:220:5:
unsafe precondition(s) violated: hint::assert_unchecked must never be called when the condition is false
stack backtrace:
0: std::panicking::begin_panic_handler
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library\std\src\panicking.rs:652
1: core::panicking::panic_nounwind_fmt::runtime
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library\core\src\panicking.rs:110
2: core::panicking::panic_nounwind_fmt
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library\core\src\panicking.rs:120
3: core::panicking::panic_nounwind
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library\core\src\panicking.rs:220
4: core::hint::assert_unchecked::precondition_check
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081\library\core\src\ub_checks.rs:66
5: alloc::rc::RcInnerPtr::inc_strong<alloc::rc::RcBox<std::sync::mutex::Mutex<tao::global_shortcut::ShortcutManager> > >
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081\library\alloc\src\rc.rs:3351
6: alloc::rc::impl$28::clone<std::sync::mutex::Mutex<tao::global_shortcut::ShortcutManager>,alloc::alloc::Global>
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081\library\alloc\src\rc.rs:2204
7: tauri_runtime_wry::impl$56::clone<enum2$<tauri::EventLoopMessage> >
at C:\Users\username\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tauri-runtime-wry-0.14.8\src\lib.rs:284
8: tauri_runtime_wry::impl$53::clone<enum2$<tauri::EventLoopMessage> >
at C:\Users\username\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tauri-runtime-wry-0.14.8\src\lib.rs:198
9: tauri_runtime_wry::create_ipc_handler::closure$0<enum2$<tauri::EventLoopMessage> >
at C:\Users\username\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tauri-runtime-wry-0.14.8\src\lib.rs:3410
10: alloc::boxed::impl$50::call<tuple$<ref$<tao::window::Window>,alloc::string::String>,dyn$<core::ops::function::Fn<tuple$<ref$<tao::window::Window>,alloc::string::String>,assoc$<Output,tuple$<> > > >,alloc::alloc::Global>
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081\library\alloc\src\boxed.rs:2036
11: alloc::boxed::impl$50::call<tuple$<ref$<tao::window::Window>,alloc::string::String>,dyn$<core::ops::function::Fn<tuple$<ref$<tao::window::Window>,alloc::string::String>,assoc$<Output,tuple$<> > > >,alloc::alloc::Global>
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081\library\alloc\src\boxed.rs:2036
12: wry::webview::webview2::impl$1::init_webview::closure$2
at C:\Users\username\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wry-0.24.10\src\webview\webview2\mod.rs:363
13: alloc::boxed::impl$49::call_mut<tuple$<enum2$<core::option::Option<webview2_com_sys::Microsoft::Web::WebView2::Win32::ICoreWebView2> >,enum2$<core::option::Option<webview2_com_sys::Microsoft::Web::WebView2::Win32::ICoreWebView2WebMessageReceivedEventArgs>
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081\library\alloc\src\boxed.rs:2029
14: webview2_com::callback::impl$279::Invoke
at C:\Users\username\.cargo\registry\src\index.crates.io-6f17d22bba15001f\webview2-com-0.19.1\src\callback.rs:267
15: webview2_com_sys::Microsoft::Web::WebView2::Win32::impl$2507::new::Invoke<webview2_com::callback::WebMessageReceivedEventHandler_Impl,webview2_com::callback::WebMessageReceivedEventHandler,-2>
at C:\Users\username\.cargo\registry\src\index.crates.io-6f17d22bba15001f\webview2-com-sys-0.19.0\src\Microsoft\Web\WebView2\Win32\mod.rs:65485
16: DllGetClassObject
17: DllGetClassObject
18: DllCanUnloadNow
19: DllCanUnloadNow
20: OQS_SIG_verify
21: DllCanUnloadNow
22: GetHandleVerifier
23: GetHandleVerifier
24: GetHandleVerifier
25: GetHandleVerifier
26: GetHandleVerifier
27: DllCanUnloadNow
28: DllCanUnloadNow
29: GetHandleVerifier
30: DllCanUnloadNow
31: DllCanUnloadNow
32: DllCanUnloadNow
33: GetHandleVerifier
34: GetHandleVerifier
35: DllCanUnloadNow
36: DispatchMessageW
37: DispatchMessageW
38: windows::Windows::Win32::UI::WindowsAndMessaging::DispatchMessageW
at C:\Users\username\.cargo\registry\src\index.crates.io-6f17d22bba15001f\windows-0.39.0\src\Windows\Win32\UI\WindowsAndMessaging\mod.rs:2671
39: tao::platform_impl::platform::event_loop::EventLoop<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >::run_return<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > >,tauri_runtime_wry::impl$49::run::closure_env$0<en
at C:\Users\username\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tao-0.16.9\src\platform_impl\windows\event_loop.rs:264
40: tao::platform_impl::platform::event_loop::EventLoop<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >::run<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > >,tauri_runtime_wry::impl$49::run::closure_env$0<enum2$<ta
at C:\Users\username\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tao-0.16.9\src\platform_impl\windows\event_loop.rs:218
41: tao::event_loop::EventLoop<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > > >::run<enum2$<tauri_runtime_wry::Message<enum2$<tauri::EventLoopMessage> > >,tauri_runtime_wry::impl$49::run::closure_env$0<enum2$<tauri::EventLoopMessage>,ta
at C:\Users\username\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tao-0.16.9\src\event_loop.rs:179
42: tauri_runtime_wry::impl$49::run<enum2$<tauri::EventLoopMessage>,tauri::app::impl$18::run::closure_env$0<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> >,package_blabbr::main::closure_env$1> >
at C:\Users\username\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tauri-runtime-wry-0.14.8\src\lib.rs:2299
43: tauri::app::App<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> > >::run<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> >,package_blabbr::main::closure_env$1>
at C:\Users\username\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tauri-1.6.8\src\app.rs:868
44: package_blabbr::main
at .\src\main.rs:48
45: core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081\library\core\src\ops\function.rs:250
46: core::hint::black_box
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081\library\core\src\hint.rs:338
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread caused non-unwinding panic. aborting.
@DaveyUS Don't be scared, the rust compiler just tries to help us find problems in our code in debug mode. To clarify: It is an annoying problem to have these panics during development. But 1. They are debug asserts, just make sure to compile your code in release mode and the panics should go away. 2. The problems have potentially been there for a very long time. It is only now with rust 1.78 that we get these panics during development. Please have a look here at: https://blog.rust-lang.org/2024/05/02/Rust-1.78.0.html
I was mostly joking about being scared, but your comment did put me at ease. I really appreciate the quick response!
Seems like crashing the entire app to alert you that there could maybe be an issue is a pretty weird decision by the people developing rust. A friendlier experience would be to silently alert or have an alert that requires input when you go to build. I'm sure there's more to it that I don't understand though. Oh well, in the meantime I guess ill downgrade since I was having no problems on the previous version. Cheers!
I have the same error, It's look like this thread 'main' panicked at library/core/src/panicking.rs:220:5: unsafe precondition(s) violated: hint::assert_unchecked must never be called when the condition is false stack backtrace: 0: 0x105618308 - std::backtrace_rs::backtrace::libunwind::trace::he4f0a5f56afe8e37 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5 1: 0x105618308 - std::backtrace_rs::backtrace::trace_unsynchronized::habb302958e80f800 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x105618308 - std::sys_common::backtrace::_print_fmt::h9819d35e2a5cda77 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:68:5 3: 0x105618308 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1f3776e0b5c7517d at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:44:22 4: 0x10563983c - core::fmt::rt::Argument::fmt::h626862aa6242248a at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/fmt/rt.rs:165:63 5: 0x10563983c - core::fmt::write::heedef092c8c0962e at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/fmt/mod.rs:1157:21 6: 0x105614914 - std::io::Write::write_fmt::h7178e8e2ea928914 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/io/mod.rs:1832:15 7: 0x105618160 - std::sys_common::backtrace::_print::ha0f584bc7bfb9d2b at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:47:5 8: 0x105618160 - std::sys_common::backtrace::print::h417292deb95532ed at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:34:9 9: 0x10561945c - std::panicking::default_hook::{{closure}}::h0cb68f1228c4613a 10: 0x105619150 - std::panicking::default_hook::h24535936bc1f51de at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:298:9 11: 0x105619d14 - std::panicking::rust_panic_with_hook::h5db4d2345b297bed at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:795:13 12: 0x105619718 - std::panicking::begin_panic_handler::{{closure}}::h3fd558f09a0d5492 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:656:13 13: 0x105618790 - std::sys_common::backtrace::__rust_end_short_backtrace::hfc76eebe1ce501b2 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:171:18 14: 0x1056194b4 - rust_begin_unwind at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:652:5 15: 0x1056667d4 - core::panicking::panic_nounwind_fmt::runtime::h6aaba2885d9c2d14 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/panicking.rs:110:18 16: 0x1056667d4 - core::panicking::panic_nounwind_fmt::hcce2987b0dd42723 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/panicking.rs:120:5 17: 0x10566684c - core::panicking::panic_nounwind::h355f878b46c24ec3 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/panicking.rs:220:5 18: 0x104cce57c - core::hint::assert_unchecked::precondition_check::hd72986fed130b009 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/ub_checks.rs:66:21 19: 0x104d43ae0 - core::hint::assert_unchecked::hc947ec580814ff2c at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/ub_checks.rs:73:17 20: 0x104d43ae0 - alloc::rc::RcInnerPtr::inc_strong::h8cd1f9c1fac8d986 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/alloc/src/rc.rs:3351:13 21: 0x104d47814 - <alloc::rc::Rc<T,A> as core::clone::Clone>::clone::h2b82f8129b425879 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/alloc/src/rc.rs:2204:13 22: 0x10487c3d0 - <tauri_runtime_wry::Wry<T> as tauri_runtime::Runtime<T>>::run::{{closure}}::h8ae5b9180c24de2b at /Users/liangmi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tauri-runtime-wry-0.14.9/src/lib.rs:2334:36 23: 0x1049064c4 - <tao::platform_impl::platform::app_state::EventLoopHandler<T> as tao::platform_impl::platform::app_state::EventHandler>::handle_nonuser_event::{{closure}}::h36f2f8c1b0695251 at /Users/liangmi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tao-0.16.9/src/platform_impl/macos/app_state.rs:105:9 24: 0x1049068e4 - tao::platform_impl::platform::app_state::EventLoopHandler<T>::with_callback::ha25fcfe8d9a8e70f at /Users/liangmi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tao-0.16.9/src/platform_impl/macos/app_state.rs:79:7 25: 0x10490622c - <tao::platform_impl::platform::app_state::EventLoopHandler<T> as tao::platform_impl::platform::app_state::EventHandler>::handle_nonuser_event::hfe37899ffc54bb92 at /Users/liangmi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tao-0.16.9/src/platform_impl/macos/app_state.rs:100:5 26: 0x104ee3f5c - tao::platform_impl::platform::app_state::Handler::handle_nonuser_event::h58e67992a9353a8a at /Users/liangmi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tao-0.16.9/src/platform_impl/macos/app_state.rs:208:11 27: 0x104ee4e44 - tao::platform_impl::platform::app_state::AppState::wakeup::hfb8459743b10ff58 at /Users/liangmi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tao-0.16.9/src/platform_impl/macos/app_state.rs:336:5 28: 0x104eac5f4 - tao::platform_impl::platform::observer::control_flow_begin_handler::{{closure}}::h0d6df3290ed64ea0 at /Users/liangmi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tao-0.16.9/src/platform_impl/macos/observer.rs:164:11 29: 0x104eac538 - tao::platform_impl::platform::observer::control_flow_handler::{{closure}}::h343f78f5c6f73871 at /Users/liangmi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tao-0.16.9/src/platform_impl/macos/observer.rs:148:5 30: 0x104efbd10 - std::panicking::try::do_call::h8d8c2c08c7e8246c at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:559:40 31: 0x104f01468 - ___rust_try 32: 0x104efbb68 - std::panicking::try::h7d338be0e0c67153 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:523:19 33: 0x104ec2fb0 - std::panic::catch_unwind::hf0f8f8bf9edda322 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panic.rs:149:14 34: 0x104eaec58 - tao::platform_impl::platform::event_loop::stop_app_on_panic::h2c57cb8d4347bd02 at /Users/liangmi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tao-0.16.9/src/platform_impl/macos/event_loop.rs:236:9 35: 0x104eac334 - tao::platform_impl::platform::observer::control_flow_handler::hb6c8a22b27c37e82 at /Users/liangmi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tao-0.16.9/src/platform_impl/macos/observer.rs:146:3 36: 0x104eac578 - tao::platform_impl::platform::observer::control_flow_begin_handler::hd92f96ca443f125f at /Users/liangmi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tao-0.16.9/src/platform_impl/macos/observer.rs:159:5 37: 0x1992a987c - <unknown> 38: 0x1992a9768 - <unknown> 39: 0x1992a913c - <unknown> 40: 0x1992a8434 - <unknown> 41: 0x1a3a4c19c - <unknown> 42: 0x1a3a4bfd8 - <unknown> 43: 0x1a3a4bd30 - <unknown> 44: 0x19cb07d68 - <unknown> 45: 0x19d2fd808 - <unknown> 46: 0x19cafb09c - <unknown> 47: 0x104de8548 - <() as objc::message::MessageArguments>::invoke::h95009f0c99acc6af at /Users/liangmi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc-0.2.7/src/message/mod.rs:128:17 48: 0x104e10914 - objc::message::platform::send_unverified::{{closure}}::heecdccf4b16c0567 at /Users/liangmi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc-0.2.7/src/message/apple/mod.rs:27:9 49: 0x104e00c88 - objc_exception::try::{{closure}}::h3a4b25cd3a7464ed at /Users/liangmi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc_exception-0.1.2/src/lib.rs:68:31 50: 0x104dfe034 - objc_exception::try_no_ret::try_objc_execute_closure::h00b9ee79475bcd38 at /Users/liangmi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc_exception-0.1.2/src/lib.rs:34:9 51: 0x104f6ef54 - RustObjCExceptionTryCatch at /Users/liangmi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc_exception-0.1.2/extern/exception.m:10:9 52: 0x104dfde90 - objc_exception::try_no_ret::hf65ed1bbfc625fad at /Users/liangmi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc_exception-0.1.2/src/lib.rs:44:19 53: 0x104dffaa4 - objc_exception::try::h8d9bc39268b46afa at /Users/liangmi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc_exception-0.1.2/src/lib.rs:67:9 54: 0x104de79a8 - objc::exception::try::h16605301680c4ae8 at /Users/liangmi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc-0.2.7/src/exception.rs:8:5 55: 0x104e0c604 - objc::message::platform::send_unverified::h8144f1941a5c0ac2 at /Users/liangmi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc-0.2.7/src/message/mod.rs:12:9 56: 0x104819434 - objc::message::send_message::he6747b19b33c9bce at /Users/liangmi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc-0.2.7/src/message/mod.rs:178:5 57: 0x104819434 - tao::platform_impl::platform::event_loop::EventLoop<T>::run_return::hc1b56b4602e8c37f at /Users/liangmi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tao-0.16.9/src/platform_impl/macos/event_loop.rs:193:16 58: 0x10481a2b8 - tao::platform_impl::platform::event_loop::EventLoop<T>::run::hc6125316cfa8f4bd at /Users/liangmi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tao-0.16.9/src/platform_impl/macos/event_loop.rs:160:21 59: 0x10482f3e8 - tao::event_loop::EventLoop<T>::run::h8f2a0d3d29ee66e9 at /Users/liangmi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tao-0.16.9/src/event_loop.rs:179:5 60: 0x10487c0dc - <tauri_runtime_wry::Wry<T> as tauri_runtime::Runtime<T>>::run::h749d69a211c60062 at /Users/liangmi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tauri-runtime-wry-0.14.9/src/lib.rs:2299:5 61: 0x10492dcc8 - tauri::app::App<R>::run::h489e832713d2f6a5 at /Users/liangmi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tauri-1.7.1/src/app.rs:868:5 62: 0x10492dfdc - tauri::app::Builder<R>::run::h46b93ffc3d4e4b45 at /Users/liangmi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tauri-1.7.1/src/app.rs:1727:5 63: 0x1047e4a90 - bw_fkdr::main::hca721238d6183008 at /Users/liangmi/code/bw_fkdr/src-tauri/src/main.rs:10:5 64: 0x1049dec40 - core::ops::function::FnOnce::call_once::hce1b4c722b75bac0 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/ops/function.rs:250:5 65: 0x1047cd918 - std::sys_common::backtrace::__rust_begin_short_backtrace::h4965bcbe124c34e3 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:155:18 66: 0x1048a7894 - std::rt::lang_start::{{closure}}::h3e6df5239cd97dff at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/rt.rs:159:18 67: 0x10560e918 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h2f86a413382a979d at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/ops/function.rs:284:13 68: 0x10560e918 - std::panicking::try::do_call::hd40c9eb4d233b111 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:559:40 69: 0x10560e918 - std::panicking::try::h13ac68ffa70c387b at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:523:19 70: 0x10560e918 - std::panic::catch_unwind::habea7b6fc986e966 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panic.rs:149:14 71: 0x10560e918 - std::rt::lang_start_internal::{{closure}}::h6b16436250c3cf62 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/rt.rs:141:48 72: 0x10560e918 - std::panicking::try::do_call::h9970b928a0b20951 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:559:40 73: 0x10560e918 - std::panicking::try::h4dfbe3cb4cc8f253 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:523:19 74: 0x10560e918 - std::panic::catch_unwind::hf6a5e1e8ce5a10f5 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panic.rs:149:14 75: 0x10560e918 - std::rt::lang_start_internal::hecc68fef83c8f44d at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/rt.rs:141:20 76: 0x1048a7860 - std::rt::lang_start::h23f9c6ea6cc082a9 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/rt.rs:158:17 77: 0x1047e51e8 - _main thread caused non-unwinding panic. aborting.
and I never use Rc and unsafe block, I always use Arc and some other things, I have about 1.5k line of code, and there are no the number of line in the stack. So I don't know how to fix this at all
Describe the bug
We are experiencing
Unsafe Precondition Violation
s during development. I could identify the check being triggered while cloningDispatcherMainThreadContext
. Specifically while cloning the innerglobal_shortcut_manager
which is anRc
.DispatcherMainThreadContext
implsSend
andSync
manually with this safety explanation:// SAFETY: we ensure this type is only used on the main thread.
. It seems that our code somehow managed to find a way to violate the rules.Possible solution
I forked this repo and managed to fix the issue by replacing the
Rc
with anArc
. I don't know how big of an impact this has on performance. If you decide that this is the way to go I am happy to create a PR.Note:
This issue was introduced by rust 1.78.0 and should only happen in debug builds. See: https://blog.rust-lang.org/2024/05/02/Rust-1.78.0.html#asserting-unsafe-preconditions
Reproduction
Unfortunately I don't have the time to create a minimal reproducable example but wanted you know anyway.
Expected behavior
Condition check to pass
Full
tauri info
outputStack trace
Additional context