jni--‘jni_internal.cc:616] JNI FatalError called,RegisterNatives failed,导致system_server crash

 

 

目录

  • 一、概述
  • 二、实例
  • 三、总结

一、概述

 

二、实例

错误:

可以看一下具体份回溯,这里把具体的出错点贴上。这里主要是

java.lang.System.loadLibrary里加载jni so库出错,具体的那个service就不贴出来了。

[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   | stack=0xf6329bf3e000-0xf6329bf40000 stackSize=1009KB
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   | held mutexes=
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   kernel: (couldn't read /proc/self/task/3519/stack)
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   native: #00 pc 000000000006f6cc  /system/lib64/libc.so (__ioctl+4)
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   native: #03 pc 000000000001430c  /system/lib64/libhwbinder.so (android::hardware::IPCThreadState::getAndExecuteCommand()+20)
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   native: #07 pc 00000000000b4b34  /system/lib64/libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*)+140)
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   native: #08 pc 0000000000083114  /system/lib64/libc.so (__pthread_start(void*)+36)
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   native: #09 pc 00000000000233bc  /system/lib64/libc.so (__start_thread+68)
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   (no managed stack frames)
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558] 
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   | sysTid=3520 nice=0 cgrp=default sched=0/0 handle=0xf6329bf3b4f0
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   | state=S schedstat=( 649440 178320 7 ) utm=0 stm=0 core=2 HZ=100
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   | stack=0xf6329be38000-0xf6329be3a000 stackSize=1041KB
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   | held mutexes=
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   native: #01 pc 00000000000141c0  /system/lib64/libutils.so (android::Looper::pollInner(int)+144)
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   at android.os.MessageQueue.nativePollOnce(Native method)
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   at android.os.MessageQueue.next(MessageQueue.java:326)
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   at android.os.Looper.loop(Looper.java:160)
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   at android.os.HandlerThread.run(HandlerThread.java:65)
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558] 
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558] "GraphicsStats-disk" prio=6 tid=65 Native
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   | group="" sCount=1 dsCount=0 flags=1 obj=0x12ce8cf0 self=0xf6329d8e0c00
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   | sysTid=3522 nice=10 cgrp=default sched=0/0 handle=0xf6329be354f0
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   | state=S schedstat=( 482520 331080 6 ) utm=0 stm=0 core=2 HZ=100
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   | held mutexes=
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   kernel: (couldn't read /proc/self/task/3522/stack)
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   native: #02 pc 000000000001408c  /system/lib64/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+60)
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   native: #03 pc 0000000000120efc  /system/lib64/libandroid_runtime.so (android::android_os_MessageQueue_nativePollOnce(_JNIEnv*, _jobject*, long, int)+44)
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   at android.os.Looper.loop(Looper.java:160)
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   at android.os.HandlerThread.run(HandlerThread.java:65)
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558] 
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558] Aborting thread:
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558] "main" prio=6 tid=1 Runnable
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   | group="" sCount=0 dsCount=0 flags=0 obj=0x73d8fa80 self=0xf632b9014c00
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   | stack=0xfffff66e7000-0xfffff66e9000 stackSize=8MB
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   | held mutexes= "abort lock" "mutator lock"(shared held)
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   native: #00 pc 00000000003c7324  /system/lib64/libart.so (art::DumpNativeStack(std::__1::basic_ostream>&, int, BacktraceMap*, char const*, art::ArtMethod*, void*, bool)+220)
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   native: #03 pc 000000000046ad0c  /system/lib64/libart.so (art::Runtime::Abort(char const*)+1220)
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   native: #04 pc 0000000000008d2c  /system/lib64/libbase.so (android::base::LogMessage::~LogMessage()+724)
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   native: #06 pc 00000000000e7a74  /system/lib64/libart.so (art::(anonymous namespace)::CheckJNI::FatalError(_JNIEnv*, char const*)+708)
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   native: #07 pc 00000000000024a4  /system/lib64/libnativehelper.so (jniRegisterNativeMethods+212)
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   native: #11 pc 0000000000114bc8  /system/framework/arm64/boot.oat (offset 114000) (java.lang.Runtime.nativeLoad [DEDUPED]+200)
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   native: #13 pc 000000000018a8b0  /system/framework/arm64/boot.oat (offset 114000) (java.lang.System.loadLibrary+96)
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   native: #14 pc 000000000055cc4c  /system/lib64/libart.so (art_quick_invoke_static_stub+604)
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   native: #17 pc 000000000027c36c  /system/lib64/libart.so (bool art::interpreter::DoCall(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+948)
[10:11:02]07-27 22:16:11.517  3258  3258 F system_server: runtime.cc:558]   native: #19 pc 000000000054f214  /system/lib64/libart.so (ExecuteMterpImpl+14612)
[10:11:02]07-27 22:16:11.518  3258  3258 F system_server: runtime.cc:558]   native: #20 pc 000000000019928c  /system/framework/oat/arm64/services.vdex (com.android.server.idste.device.DeviceSrv.+20)
[10:11:02]07-27 22:16:11.518  3258  3258 F system_server: runtime.cc:558]   native: #24 pc 000000000055cc4c  /system/lib64/libart.so (art_quick_invoke_static_stub+604)
[10:11:02]07-27 22:16:11.518  3258  3258 F system_server: runtime.cc:558]   native: #25 pc 00000000000cf760  /system/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+232)
[10:11:02]07-27 22:16:11.518  3258  3258 F system_server: runtime.cc:558]   native: #29 pc 000000000011420c  /system/framework/arm64/boot.oat (offset 114000) (java.lang.Object.internalClone [DEDUPED]+124)
[10:11:02]07-27 22:16:11.518  3258  3258 F system_server: runtime.cc:558]   at java.lang.Runtime.loadLibrary0(Runtime.java:1014)
[10:11:02]07-27 22:16:11.518  3258  3258 F system_server: runtime.cc:558]   - locked <0x0f2a2132> (a java.lang.Runtime)
[10:11:02]07-27 22:16:11.518  3258  3258 F system_server: runtime.cc:558]   at java.lang.System.loadLibrary(System.java:1669)

根据上面的错误,定位到时 'jni_internal.cc:616] JNI FatalError called,RegisterNatives failed,这里出错,最后发现这里的签名少了一个;

[10:11:03]07-27 22:16:11.595  3532  3532 I crash_dump64: performing dump of process 3258 (target tid = 3258)
[10:11:03]07-27 22:16:11.614  3532  3532 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
[10:11:03]07-27 22:16:11.614  3532  3532 F DEBUG   : Build f[   85.541300] type=1400 audit(1595859397.663:70): avc: denied { dac_read_search } for pid=1 comm="init" capability=2 scontext=u:r:init:s0 tcontext=u:r:init:s0 tclass=capability permissive=1
[10:11:03]07-27 22:16:11.614  3532  3532 F DEBUG   : Revision: '0'
[10:11:03]07-27 22:16:11.614  3532  3532 F DEBUG   : ABI: 'arm64'
[10:11:03]07-27 22:16:11.614  3532  3532 F DEBUG   : pid: 3258, tid: 3258, name: system_server  >>> system_server <<<
[10:11:03]07-27 22:16:11.614  3532  3532 F DEBUG   : signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
[10:11:03]07-27 22:16:11.614  3532  3532 F DEBUG   : Abort message: 'jni_internal.cc:616] JNI FatalError called: RegisterNatives failed for 
[10:11:03]07-27 22:16:11.615  3532  3532 F DEBUG   :     x0  0000000000000000  x1  0000000000000cba  x2  0000000000000006  x3  0000000000000008
[10:11:03]07-27 22:16:11.615  3532  3532 F DEBUG   :     x4  0000f632bdf05000  x5  0000f632bdf05000  x6  0000f632bdf05000  x7  0000000000006e48
[10:11:03]07-27 22:16:11.615  3532  3532 F DEBUG   :     x8  0000000000000083  x9  0000f632ba1f89d8  x10 fffffff87ffffbdf  x11 0000000000000001
[10:11:03]07-27 22:16:11.615  3532  3532 F DEBUG   :     x12 ffffffffffffc000  x13 ffffffffa0e11e8d  x14 0000000009fe78e0  x15 0000000000000000
[10:11:03]07-27 22:16:11.615  3532  3532 F DEBUG   :     x16 0000f632ba2312c8  x17 0000f632ba16f2d8  x18 0000000000000000  x19 0000000000000cba
[10:11:03]07-27 22:16:11.615  3532  3532 F DEBUG  [   85.691255] healthd: battery l=85 v=3 t=35.0 h=2 st=2 c=400 fc=4000000 cc=32 chg=a
[10:11:03] :     x20 0000000000000cba  x21 [   85.702007] type=1400 audit(1595859400.243:71): avc: denied { dac_read_search } for pid=3140 comm="Binder:3140_6" capability=2 scontext=u:r:installd:s0 tcontext=u:r:installd:s0 tclass=capability permissive=1
[10:11:03]0000000000000083  x22 0000f632b90[   85.707289] healthd: battery l=85 v=3 t=35.0 h=2 st=2 c=400 fc=4000000 cc=32 chg=a
[10:11:03]14c00  x23 0000f632b0a3b170
[10:11:03]07-2[   85.733729] type=1400 audit(1595859400.407:72): avc: denied { read } for pid=3099 comm="[email protected]" name="stat" dev="sysfs" ino=21829 scontext=u:r:hal_health_default:s0 tcontext=u:object_r:sysfs:s0 tclass=file permissive=1
[10:11:03]7 22:16:11.615  3532  3532 F DEBU[   85.757098] type=1400 audit(1595859400.407:72): avc: denied { read } for pid=3099 comm="[email protected]" name="stat" dev="sysfs" ino=21829 scontext=u:r:hal_health_default:s0 tcontext=u:object_r:sysfs:s0 tclass=file permissive=1
[10:11:03]G   :     x24 0000000000000058  x[   85.780535] type=1400 audit(1595859400.411:73): avc: denied { open } for pid=3099 comm="[email protected]" path="/sys/devices/platform/30b40000.usdhc/mmc_host/mmc0/mmc0:0001/block/mmcblk0/stat" dev="sysfs" ino=21829 scontext=u:r:hal_health_default:s0 tcontext=u:object_r:sysfs:s0 tclass=file permissive=1
[10:11:03]25 0000f632b8fdec28  x26 0000f632b8f072c0  x27 0000f632b8f072f1
[10:11:03]07-27 22:16:11.615  3532  3532 F DEBUG   :     x28 0000f632b8f06a23  x29 0000fffff6ee14c0
[10:11:03]07-27 22:16:11.615  3532  3532 F DEBUG   :     sp  0000fffff6ee1480  lr  0000f632ba163a90  pc  0000f632ba163abc
[10:11:03]07-27 22:16:11.652  3229  3239 D BootAnimation: BootAnimation::android,enter render mAndroid[1]
[10:11:03]07-27 22:16:11.662  3532  3532 F DEBUG   : 
[10:11:03]07-27 22:16:11.662  3532  3532 F DEBUG   : backtrace:
[10:11:03]07-27 22:16:11.662  3532  3532 F DEBUG   :     #00 pc 0000000000021abc  /system/lib64/libc.so (abort+124)
[10:11:03]07-27 22:16:11.662  3532  3532 F DEBUG   :     #01 pc 000000000046ad00  /system/lib64/libart.so (art::Runtime::Abort(char const*)+1208)
[10:11:03]07-27 22:16:11.662  3532  3532 F DEBUG   :     #02 pc 0000000000008d2c  /system/lib64/libbase.so (android::base::LogMessage::~LogMessage()+724)
[10:11:03]07-27 22:16:11.662  3532  3532 F DEBUG   :     #03 pc 00000000003310d4  /system/lib64/libart.so (art::JNI::FatalError(_JNIEnv*, char const*)+196)
[10:11:03]07-27 22:16:11.662  3532  3532 F DEBUG   :     #04 pc 00000000000e7a74  /system/lib64/libart.so (art::(anonymous namespace)::CheckJNI::FatalError(_JNIEnv*, char const*)+708)
[10:11:03]07-27 22:16:11.662  3532  3532 F DEBUG   :     #05 pc 00000000000024a4  /system/lib64/libnativehelper.so (jniRegisterNativeMethods+212)

三、总结

在Android system service中添加jni函数的时候,一定要谨慎,不然整个system server启动不了,只能重新烧rom。虽然有几次前面添加的错误了,但这里的签名还是漏了一个";".

你可能感兴趣的:(android,jni编程)