denoland / deno_core

The core engine at the heart of Deno
MIT License
296 stars 96 forks source link

`deno_core` init crash on Android aarch64 #738

Open secext2022 opened 6 months ago

secext2022 commented 6 months ago

core/examples/hello_world.rs can not run on Android, it just crash when init.

deno_core v0.280.0 rusty_v8 v0.91.1

build command:

export PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH
export CC_aarch64_linux_android=aarch64-linux-android28-clang
export CXX_aarch64_linux_android=aarch64-linux-android28-clang++
export AR_aarch64_linux_android=llvm-ar
export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=aarch64-linux-android28-clang

cd core
cargo build --example hello_world --release --target aarch64-linux-android

Then use adb push to send hello_world binary to Android phone, and adb shell:

violet:/data/local/tmp $ ls -l hello_world                                                                            
-rwxrwxrwx 1 shell shell 36623592 2024-05-12 04:00 hello_world
violet:/data/local/tmp $ ./hello_world                                                                                
deno_core/hello_world::main()
before JsRuntime::new()
Bus error 
135|violet:/data/local/tmp $ 

Add these print code:

diff --git a/core/examples/hello_world.rs b/core/examples/hello_world.rs
index 6e99349..8e3c176 100644
--- a/core/examples/hello_world.rs
+++ b/core/examples/hello_world.rs
@@ -15,6 +15,9 @@ fn op_sum(#[serde] nums: Vec<f64>) -> Result<f64, deno_core::error::AnyError> {
 }

 fn main() {
+  // FIXME
+  println!("deno_core/hello_world::main()");
+
   // Build a deno_core::Extension providing custom ops
   const DECL: OpDecl = op_sum();
   let ext = Extension {
@@ -23,12 +26,14 @@ fn main() {
     ..Default::default()
   };

+  println!("before JsRuntime::new()");
   // Initialize a runtime instance
   let mut runtime = JsRuntime::new(RuntimeOptions {
     extensions: vec![ext],
     ..Default::default()
   });

+  println!("before runtime.execute_script()");
   // Now we see how to invoke the op we just defined. The runtime automatically
   // contains a Deno.core object with several functions for interacting with it.
   // You can find its definition in core.js.
@@ -57,4 +62,6 @@ try {
 "#,
     )
     .unwrap();
+
+  println!("end of main");
 }

it seems crash happen in JsRuntime::new()

secext2022 commented 6 months ago

I use the same method to compile rusty_v8-v0.91.1/examples/hello_world.rs and it works fine:

violet:/data/local/tmp $ ls -l hello_world
-rwxrwxrwx 1 shell shell 23712208 2024-05-12 03:42 hello_world
violet:/data/local/tmp $ ./hello_world
Hello World!
3 + 4 = 7
violet:/data/local/tmp $ 

so maybe the BUG is in deno_core.

AuTsing commented 6 months ago
********** Crash dump: **********
Build fingerprint: 'Xiaomi/cepheus/cepheus:13/TQ3A.230901.001/1700048355:user/release-keys'
#00 0x000000000169b5fa /data/local/tmp/deno_core_tester/deno_core_tester (offset 0x277c000)
                                                                          v8::internal::CppHeap::ShouldFinalizeIncrementalMarking() const
                                                                          ./../../../../project/v8/src/heap/cppgc-js/cpp-heap.cc:823:46
#01 0x000000000157ae44 /data/local/tmp/deno_core_tester/deno_core_tester
v8::String::NewExternalOneByte(v8::Isolate*, v8::String::ExternalOneByteStringResource*)
./../../../../project/v8/src/api/api.cc:7569:17
#02 0x00000000013e79bc /data/local/tmp/deno_core_tester/deno_core_tester                                                                                    v8::string::_$LT$impl$u20$v8..data..String$GT$::new_from_onebyte_const::_$u7b$$u7b$closure$u7d$$u7d$::he49368b64e9358c2
/home/autsing/.cargo/registry/src/index.crates.io-6f17d22bba15001f/v8-0.91.1/src/string.rs:524:9
#03 0x00000000012648cc /data/local/tmp/deno_core_tester/deno_core_tester
v8::scope::HandleScope$LT$$LP$$RP$$GT$::cast_local::h4571edd0760c36c0
/home/autsing/.cargo/registry/src/index.crates.io-6f17d22bba15001f/v8-0.91.1/src/scope.rs:239:21
v8::string::_$LT$impl$u20$v8..data..String$GT$::new_from_onebyte_const::h4a09757415235853
/home/autsing/.cargo/registry/src/index.crates.io-6f17d22bba15001f/v8-0.91.1/src/string.rs:523:7
deno_core::fast_string::FastString::v8_string::hac520e289ba5272f                                                                                            /home/autsing/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deno_core-0.280.0/fast_string.rs:250:9
#04 0x00000000012633e0 /data/local/tmp/deno_core_tester/deno_core_tester                                                                                    deno_core::fast_string::FastStaticString::v8_string::h469444a3780ceba1
/home/autsing/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deno_core-0.280.0/fast_string.rs:51:5
#05 0x00000000011abfb0 /data/local/tmp/deno_core_tester/deno_core_tester
deno_core::runtime::bindings::initialize_deno_core_namespace::ha7501f9b50daec73
/home/autsing/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deno_core-0.280.0/runtime/bindings.rs:219:18
#06 0x00000000011c62a8 /data/local/tmp/deno_core_tester/deno_core_tester
deno_core::runtime::jsruntime::JsRuntime::new_inner::h8f22405992dbfb6e
/home/autsing/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deno_core-0.280.0/runtime/jsruntime.rs:860:7
#07 0x00000000011c3f34 /data/local/tmp/deno_core_tester/deno_core_tester                                                                                    deno_core::runtime::jsruntime::JsRuntime::new::h6d1905f499569ef7
/home/autsing/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deno_core-0.280.0/runtime/jsruntime.rs:619:11
#08 0x00000000010ef9a8 /data/local/tmp/deno_core_tester/deno_core_tester
deno_core_tester::main::h576d7b573f2b4241                                                                                                                   /home/autsing/Gits/test_build_deno_core/src/main.rs:27:23
#09 0x00000000010edffc /data/local/tmp/deno_core_tester/deno_core_tester
core::ops::function::FnOnce::call_once::h51167d1a3094403f                                                                                                   /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:250:5
#10 0x00000000010ed0a8 /data/local/tmp/deno_core_tester/deno_core_tester                                                                                    std::sys_common::backtrace::__rust_begin_short_backtrace::hf250caf38c5a453f                                                                                 /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/sys_common/backtrace.rs:155:18
#11 0x00000000010f3c30 /data/local/tmp/deno_core_tester/deno_core_tester
std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::h043b3f29a11671bf
/rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/rt.rs:166:18
#12 0x0000000002751f08 /data/local/tmp/deno_core_tester/deno_core_tester
core::ops::function::impls::_$LT$impl$u20$core..ops..function..FnOnce$LT$A$GT$$u20$for$u20$$RF$F$GT$::call_once::h9983aae1f0c22e8a
/rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:284:13
std::panicking::try::do_call::h066238e64a26bede
/rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:552:40
std::panicking::try::h33c132dbcd21b2c1
/rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:516:19
std::panic::catch_unwind::h105dc9d93356acbb
/rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panic.rs:142:14
std::rt::lang_start_internal::_$u7b$$u7b$closure$u7d$$u7d$::h541039ddd50eb0d5
/rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/rt.rs:148:48
std::panicking::try::do_call::h6d067e65329ff03d
/rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:552:40
std::panicking::try::h68073e7dd5111ae0
/rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:516:19
std::panic::catch_unwind::h6d258ee41ea7e92f
/rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panic.rs:142:14
std::rt::lang_start_internal::h71c6fdbbf3980bb9
/rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/rt.rs:148:20
#13 0x00000000010f3c00 /data/local/tmp/deno_core_tester/deno_core_tester
std::rt::lang_start::h00b44abb2a65b1de
/rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/rt.rs:165:17
#14 0x00000000010f3ba8 /data/local/tmp/deno_core_tester/deno_core_tester
main
??:0:0
#15 0x000000000004a320 /apex/com.android.runtime/lib64/bionic/libc.so (__libc_init+96) (BuildId: feb08ab3b0daed1a79b081a68ee9fbfd)
Crash dump is completed

I tried also and this may be the crash dump.

secext2022 commented 6 months ago

Crash log from adb logcat:

--------- beginning of crash
05-12 19:31:24.948  1144  1144 F libc    : Fatal signal 7 (SIGBUS), code 1 (BUS_ADRALN), fault addr 0x568c57c3de in tid 1144 (hello_world), pid 1144 (hello_world)
05-12 19:31:24.948 16567 16608 W GoogleApiManager: The service for lp1 is not available: ConnectionResult{statusCode=SERVICE_UPDATING, resolution=null, message=null}
05-12 19:31:24.952 20784 20784 D KeyguardUpdateMonitor: received broadcast android.intent.action.BATTERY_CHANGED
05-12 19:31:24.986  1191  1191 I crash_dump64: obtaining output fd from tombstoned, type: kDebuggerdTombstone
05-12 19:31:24.987  1113  1113 I /system/bin/tombstoned: received crash request for pid 1144
05-12 19:31:24.988  1191  1191 I crash_dump64: performing dump of process 1144 (target tid = 1144)
05-12 19:31:24.990  1191  1191 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
05-12 19:31:24.990  1191  1191 F DEBUG   : Build fingerprint: 'xiaomi/violet/violet:10/QKQ1.190915.002/V12.5.4.0.QFHCNXM:user/release-keys'
05-12 19:31:24.990  1191  1191 F DEBUG   : Revision: '0'
05-12 19:31:24.990  1191  1191 F DEBUG   : ABI: 'arm64'
05-12 19:31:24.991  1191  1191 F DEBUG   : Timestamp: 2024-05-12 19:31:24+0800
05-12 19:31:24.991  1191  1191 F DEBUG   : pid: 1144, tid: 1144, name: hello_world  >>> ./hello_world <<<
05-12 19:31:24.991  1191  1191 F DEBUG   : uid: 2000
05-12 19:31:24.991  1191  1191 F DEBUG   : signal 7 (SIGBUS), code 1 (BUS_ADRALN), fault addr 0x568c57c3de
05-12 19:31:24.991  1191  1191 F DEBUG   :     x0  000000568c585fe0  x1  000000568c585fe0  x2  0000000000000000  x3  000000568b380aa0
05-12 19:31:24.991  1191  1191 F DEBUG   :     x4  000000568a3a1d9a  x5  0000007c6b80a000  x6  0000000000000029  x7  000000000000000a
05-12 19:31:24.991  1191  1191 F DEBUG   :     x8  000000568c57c3de  x9  0000000000000056  x10 000000000000000a  x11 0000000000000000
05-12 19:31:24.991  1191  1191 F DEBUG   :     x12 0000000000000001  x13 000000568a3a1d66  x14 000000000000000a  x15 0000000000000002
05-12 19:31:24.991  1191  1191 F DEBUG   :     x16 000000568c5bf220  x17 0000007c6be98380  x18 0000007c6c6f4000  x19 0000007c6b918000
05-12 19:31:24.991  1191  1191 F DEBUG   :     x20 000000568c585fe0  x21 0000000000000002  x22 000000568ae108d8  x23 0000007c6b85a010
05-12 19:31:24.991  1191  1191 F DEBUG   :     x24 0000007c6b815620  x25 0000007c6b934b40  x26 0000007ff055e350  x27 0000000000000001
05-12 19:31:24.991  1191  1191 F DEBUG   :     x28 0000000000000000  x29 0000007ff055d4d0
05-12 19:31:24.991  1191  1191 F DEBUG   :     sp  0000007ff055d4d0  lr  000000568b3dc3e0  pc  000000568c57c3de
05-12 19:31:24.999  1191  1191 F DEBUG   : 
05-12 19:31:24.999  1191  1191 F DEBUG   : backtrace:
05-12 19:31:24.999  1191  1191 F DEBUG   :     NOTE: Function names and BuildId information is missing for some frames due
05-12 19:31:24.999  1191  1191 F DEBUG   :     NOTE: to unreadable libraries. For unwinds of apps, only shared libraries
05-12 19:31:24.999  1191  1191 F DEBUG   :     NOTE: found under the lib/ directory are readable.
05-12 19:31:24.999  1191  1191 F DEBUG   :       #00 pc 00000000012803de  /data/local/tmp/hello_world (offset 0x100b000)
05-12 19:31:25.014  1191  1191 E crash_dump64: cannot open libmiuindbg.so: No such file or directory
--------- beginning of system