-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Issues with crash handling for iOS for Rust 1.22.1 #46796
Comments
Unwinding across an FFI call is undefined behaviour |
Would it be safe to at least call the C backtrace function at that moment to get a backtrace that I can then use for crash reporting? |
Probably. I think the backtrace crate does this. |
According to the docs, that library doesn't support iOS. |
Also, according to the docs for The reason I'm so curious is that, without good crash reporting for rust in iOS, I don't see how I can deploy any sort of large-scale app. |
Using |
I thought this fixed it, but it wasn't enough. Based on a Stack Overflow thread, I think I've found a solution. In Rust: extern "C" {
fn platform_panic();
}
pub fn main() {
std::panic::set_hook(Box::new(|_| unsafe {
platform_panic();
}));
// stuff that might panic
} and in Swift: @_cdecl("platform_panic")
func platform_panic() {
DispatchQueue.global(qos: .userInteractive)
.sync {
fatalError()
}
} Now, the actual |
I'm using
rustc 1.22.1 (05e2e1c41 2017-11-22)
and I'm calling a simple rust function from my iOS app that just panics. The rust function is in a static library and is compiledcargo build
(debug with -O0). The architecture is aarch64-apple-ios. Here's the rust code:When I call it like this, from my root view controller:
Then when the panic occurs, in the left-hand pane of Xcode, it just shows me this generic trace:
And in the crash reporting service, Crashlytics, I just see a stack trace just like it. However, when I wrap the call to the rust function like so:
Then both the left-hand pane of Xcode as well as the crash reporting service show the correct stack trace. Can anyone help with this? I want to start using Rust in my app, but I don't feel comfortable doing so until I can monitor crashes with it.
The text was updated successfully, but these errors were encountered: