Open
Description
Bevy version
0.16
Relevant system information
iPhone 14 Pro Max, iOS 18.4.1 (real device)
What you did
I tried to catch all panics in my bevy app in order to send them to my monitoring infrastructure. It works on all platform but on iOS, a panic-in-panic happens which aborts the process, preventing me from sending the panic to the telemetry server.
std::panic::catch_unwind(|| {
let mut app = App::new();
app.add_plugins(DefaultPlugins);
app.add_systems(Startup, || panic!("this is a test panic"));
app.run();
});
What went wrong
- what were you expecting?
I was expecting my program to exit cleanly after the panic has been caught, just like it does on the other platforms I tested on (macOS and Android).
- what actually happened?
A panic-in-panic is happening somewhere in bevy. It results in an aborting panic, which cannot be caught by catch_unwind
. Unfortunately the backtrace shows <unknown> for the interesting symbols.
thread '<unnamed>' panicked at crates/client/src/lib.rs:138:37:
this is a test panic
stack backtrace:
0: 0x102448494 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hab422a1a11b8f7b3
1: 0x102464520 - core::fmt::write::hfe39fe5ff3c4c688
2: 0x10244558c - std::io::Write::write_fmt::h116d6e9d58f606e5
3: 0x102448348 - std::sys::backtrace::BacktraceLock::print::h40b74fd903632aeb
4: 0x102449390 - std::panicking::default_hook::{{closure}}::h9855a663cdb88002
5: 0x1024491c8 - std::panicking::default_hook::hf18a76756aee275a
6: 0x102449d4c - std::panicking::rust_panic_with_hook::h2883ee581935c57a
7: 0x1024497e0 - std::panicking::begin_panic_handler::{{closure}}::h8936e4f587ecc2e6
8: 0x102448948 - std::sys::backtrace::__rust_end_short_backtrace::h6cfbeafc1a5b28df
9: 0x1024494c0 - _rust_begin_unwind
10: 0x1024ff9b8 - core::panicking::panic_fmt::hb4f40d95ce1eb887
11: 0x100ec88f0 - myapp_client::run::{{closure}}::{{closure}}::h964aa8b445c7e7e6
12: 0x100ec07f8 - core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut::h09404907c1da7447
13: 0x100ec01dc - <Func as bevy_ecs::system::function_system::SystemParamFunction<fn() .> Out>>::run::h12df91a2ec1e40d3
14: 0x100ec0200 - <bevy_ecs::system::function_system::FunctionSystem<Marker,F> as bevy_ecs::system::system::System>::run_unsafe::h1fc51bcd1bcdc196
15: 0x100ec02b4 - <bevy_ecs::system::schedule_system::InfallibleSystemWrapper<S> as bevy_ecs::system::system::System>::run_unsafe::h38ad07333b28653e
16: 0x10239f204 - bevy_ecs::schedule::executor::__rust_begin_short_backtrace::run_unsafe::h733863d9ffafbf3c
17: 0x10235f034 - <async_executor::AsyncCallOnDrop<Fut,Cleanup> as core::future::future::Future>::poll::h267a5c0fe8f26b89
18: 0x102360ec8 - async_task::raw::RawTask<F,T,S,M>::run::hc264f35e34703ff4
19: 0x1017d9638 - std::sys::backtrace::__rust_begin_short_backtrace::hae7a90c17f14a4a0
20: 0x101800a68 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h5c8bc33c3d5c5274
21: 0x10244c468 - std::sys::pal::unix::thread::Thread::new::thread_start::ha28f8bde96933fc0
22: 0x228672afc - <unknown>
Encountered a panic in system `myapp_client::run::{{closure}}::{{closure}}`!
Encountered a panic in system `bevy_app::main_schedule::Main::run_main`!
thread '<unnamed>' panicked at library/core/src/panicking.rs:218:5:
panic in a function that cannot unwind
stack backtrace:
0: 0x102448494 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hab422a1a11b8f7b3
1: 0x102464520 - core::fmt::write::hfe39fe5ff3c4c688
2: 0x10244558c - std::io::Write::write_fmt::h116d6e9d58f606e5
3: 0x102448348 - std::sys::backtrace::BacktraceLock::print::h40b74fd903632aeb
4: 0x102449390 - std::panicking::default_hook::{{closure}}::h9855a663cdb88002
5: 0x1024491c8 - std::panicking::default_hook::hf18a76756aee275a
6: 0x102449d4c - std::panicking::rust_panic_with_hook::h2883ee581935c57a
7: 0x1024497e0 - std::panicking::begin_panic_handler::{{closure}}::h8936e4f587ecc2e6
8: 0x102448948 - std::sys::backtrace::__rust_end_short_backtrace::h6cfbeafc1a5b28df
9: 0x1024494c0 - _rust_begin_unwind
10: 0x1024ff9ec - core::panicking::panic_nounwind_fmt::h10a8bb1d36d76fc7
11: 0x1024ffa64 - core::panicking::panic_nounwind::h730843ac744ca085
12: 0x1024ffb50 - core::panicking::panic_cannot_unwind::h81a758f0e2e788ae
13: 0x100fd5744 - winit::platform_impl::ios::event_loop::setup_control_flow_observers::control_flow_main_end_handler::h19cf5123daf9cc31
14: 0x19e1180e0 - <unknown>
15: 0x19e117e80 - <unknown>
16: 0x19e167ca4 - <unknown>
17: 0x19e18c700 - <unknown>
18: 0x1eaccd190 - <unknown>
19: 0x1a0daa240 - <unknown>
20: 0x1a0da8470 - <unknown>
21: 0x100f71588 - winit::platform_impl::ios::event_loop::EventLoop<T>::run::h43d3193feda1c8d6
22: 0x100f64184 - core::ops::function::FnOnce::call_once{{vtable.shim}}::hbeaf0d9d7dad3ec7
23: 0x1023569ec - bevy_app::app::App::run::h500b5d24e766e6b7
24: 0x100ec885c - myapp_client::run::hf83fbac4175e70fd
25: 0x100ec00b8 - _start_app
26: 0x100ec000c - _main
thread caused non-unwinding panic. aborting.
I would happily propose a fix, but I have no idea where to look for. Any pointers will be appreciated.