Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What changed in rust_begin_unwind from Rust 1.11 to 1.12?

Tags:

android

rust

During the 1.12 beta, I built and ran code this for Android without problems:

[package]
name = "android"
version = "0.1.0"
authors = ["Author <[email protected]>"]
build = "build.rs"

[lib]
name = "mylib"
crate-type = ["cdylib"]

I use rustup and rustup target add arm-linux-androideabi.

Now when I load my Rust 1.12 library from Java code I get:

java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "rust_begin_unwind"

To temporarily fix this, I need a workaround:

#[allow(unused_variables)]
#[no_mangle]
pub extern
fn rust_begin_unwind(fmt: ::std::fmt::Arguments, file: &'static str, line: u32) -> ! {
    loop {}
}
  1. Why did unwinding become unavailable on the Android platform?
  2. How can I fix this properly? When debugging, I want to see the full stack trace in the Android IDE log window.
like image 941
fghj Avatar asked Sep 07 '25 10:09

fghj


1 Answers

Rust 1.12 introduced the MIR (Mid-level Intermediate Representation), a new translation into machine code the compiler uses. I don't know much about it but it was apparently focused largely on control flow, and rust_begin_unwind sounds reasonably likely to have been affected.

https://blog.rust-lang.org/2016/09/29/Rust-1.12.html#mir-code-generation

like image 79
Jacob Phillips Avatar answered Sep 08 '25 23:09

Jacob Phillips