Android端Signal 11(SIGSEGV) SQLite相关崩溃无法复现求排查
问题根因
这个signal 11 (SIGSEGV), code 1 (SEGV_MAPERR)崩溃和你接入的Mapbox无关,从回溯栈可以明确完整触发链路:
- 崩溃点在系统原生SQLite的
nativePrepareStatement方法,SEGV_MAPERR的含义是代码访问了未被映射到进程地址空间的内存,属于典型的野指针问题。 - 触发起点是Google Play服务内置的
MeasurementDynamite模块(对应Firebase/GA4埋点组件),该模块调用SQLiteDatabase.beginTransaction尝试开启事务时,系统发现对应的数据库文件已经损坏,随即触发系统默认的DefaultDatabaseErrorHandler.onCorruption损坏回调。 - 系统默认的损坏回调会调用
isDatabaseIntegrityOk执行完整性校验,校验过程中需要编译SQL语句,此时之前持有的数据库native指针已经因为数据库损坏被释放,最终调用nativePrepareStatement时直接访问非法内存触发崩溃。 - 本地无法复现是正常现象:该问题只在终端用户设备上出现,触发前提是GMS的测量模块数据库损坏,常见诱因包括设备存储空间耗尽、异常断电关机、部分厂商系统的SQLite实现兼容问题,测试设备很难模拟这类场景。
修复方案
- 先排除无关嫌疑:整个回溯栈没有任何Mapbox相关的native、Java调用帧,崩溃操作的是GMS自身的私有数据库,和你App的业务逻辑、Mapbox的离线缓存/数据库操作没有关系。
- 这是旧版本GMS测量模块的已知bug,在Android 10-12的部分机型上高发,可以通过以下方式降低崩溃上报量:
- 把项目中所有Google Play服务、Firebase相关依赖升级到最新正式版,Google已经在新版本的MeasurementDynamite模块中修复了数据库损坏后访问野指针的逻辑。
- 如果没有主动接入Firebase/GA4,执行
gradlew app:dependencies命令排查依赖树,找到间接引入老版本GMS组件的三方库,强制将GMS相关依赖的版本统一到最新。 - 针对App自身(包括Mapbox)使用的SQLite数据库,自定义实现
DatabaseErrorHandler,检测到数据库损坏时直接删除损坏文件重建库,不要复用系统默认的损坏处理逻辑——系统默认逻辑本身就存在指针失效后继续访问的风险,不止GMS模块,任何数据库走默认处理流程都可能触发同类崩溃。
- 不需要对这类崩溃过度焦虑:崩溃发生在GMS的插件独立进程中,本质不会直接导致App主进程闪退,部分崩溃统计平台会把插件进程的崩溃统一算到宿主App头上,才会出现后台上报量很高但你完全收不到用户对应反馈的情况。
完整崩溃回溯栈
backtrace: #00 pc 00000000000d1afc /system/lib/libandroid_runtime.so (android::nativePrepareStatement(_JNIEnv, _jclass, long long, _jstring*)+60) #00 pc 00000000002dfc83 /system/framework/arm/boot-framework.oat (art_jni_trampoline+130) #00 pc 000000000053cd13 /system/framework/arm/boot-framework.oat (android.database.sqlite.SQLiteConnection.acquirePreparedStatement+146) #00 pc 0000000000541f77 /system/framework/arm/boot-framework.oat (android.database.sqlite.SQLiteConnection.prepare+142) #00 pc 0000000000468f8f /system/framework/arm/boot-framework.oat (android.database.sqlite.SQLiteSession.prepare+190) #00 pc 0000000000546e11 /system/framework/arm/boot-framework.oat (android.database.sqlite.SQLiteProgram.<init>+368) #00 pc 000000000054443f /system/framework/arm/boot-framework.oat (android.database.sqlite.SQLiteDatabase.compileStatement+102) #00 pc 00000000000d7bc5 /apex/com.android.runtime/lib/libart.so (art_quick_invoke_stub_internal+68) #00 pc 000000000042e0e7 /apex/com.android.runtime/lib/libart.so (art_quick_invoke_stub+250) #00 pc 00000000000dffb7 /apex/com.android.runtime/lib/libart.so (art::ArtMethod::Invoke(art::Thread, unsigned int, unsigned int, art::JValue*, char const*)+174) #00 pc 0000000000210691 /apex/com.android.runtime/lib/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread, art::ArtMethod, art::ShadowFrame*, unsigned short, art::JValue*)+280) #00 pc 000000000020bfd3 /apex/com.android.runtime/lib/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod, art::Thread, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+774) #00 pc 00000000004233b9 /apex/com.android.runtime/lib/libart.so (MterpInvokeVirtual+556) #00 pc 00000000000d2814 /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_virtual+20) #00 pc 00000000003b9c26 /system/framework/framework.jar (android.database.sqlite.SQLiteDatabase.isDatabaseIntegrityOk+222) #00 pc 0000000000423609 /apex/com.android.runtime/lib/libart.so (MterpInvokeVirtual+1148) #00 pc 00000000000d2814 /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_virtual+20) #00 pc 00000000003ae840 /system/framework/framework.jar (android.database.DefaultDatabaseErrorHandler.diagnoseDatabase+128) #00 pc 0000000000425479 /apex/com.android.runtime/lib/libart.so (MterpInvokeDirect+980) #00 pc 00000000000d2914 /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_direct+20) #00 pc 00000000003af0c4 /system/framework/framework.jar (android.database.DefaultDatabaseErrorHandler.onCorruption+304) #00 pc 0000000000424aa9 /apex/com.android.runtime/lib/libart.so (MterpInvokeInterface+1432) #00 pc 00000000000d2a14 /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_interface+20) #00 pc 00000000003bbf44 /system/framework/framework.jar (android.database.sqlite.SQLiteDatabase.onCorruption+80) #00 pc 00000000001ebf0d /apex/com.android.runtime/lib/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.65484028430099480)+192) #00 pc 00000000001f06f1 /apex/com.android.runtime/lib/libart.so (art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*)+124) #00 pc 0000000000417c59 /apex/com.android.runtime/lib/libart.so (artQuickToInterpreterBridge+808) #00 pc 00000000000dc5a1 /apex/com.android.runtime/lib/libart.so (art_quick_to_interpreter_bridge+32) #00 pc 0000000000542df5 /system/framework/arm/boot-framework.oat (android.database.sqlite.SQLiteDatabase.beginTransaction+276) #00 pc 000000000054432d /system/framework/arm/boot-framework.oat (android.database.sqlite.SQLiteDatabase.beginTransaction+44) #00 pc 00000000000d7bc5 /apex/com.android.runtime/lib/libart.so (art_quick_invoke_stub_internal+68) #00 pc 000000000042e0e7 /apex/com.android.runtime/lib/libart.so (art_quick_invoke_stub+250) #00 pc 00000000000dffb7 /apex/com.android.runtime/lib/libart.so (art::ArtMethod::Invoke(art::Thread, unsigned int, unsigned int, art::JValue*, char const*)+174) #00 pc 0000000000210691 /apex/com.android.runtime/lib/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread, art::ArtMethod, art::ShadowFrame*, unsigned short, art::JValue*)+280) #00 pc 000000000020bfd3 /apex/com.android.runtime/lib/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod, art::Thread, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+774) #00 pc 00000000004233b9 /apex/com.android.runtime/lib/libart.so (MterpInvokeVirtual+556) #00 pc 00000000000d2814 /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_virtual+20) #00 pc 00000000000218f2 /data/user_de/0/com.google.android.gms/app_chimera/m/0000005f/MeasurementDynamite.apk (ik.r+90) #00 pc 0000000000423609 /apex/com.android.runtime/lib/libart.so (MterpInvokeVirtual+1148) #00 pc 00000000000d2814 /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_virtual+20) #00 pc 000000000002e368 /data/user_de/0/com.google.android.gms/app_chimera/m/0000005f/MeasurementDynamite.apk (ma.K+72) #00 pc 0000000000423609 /apex/com.android.runtime/lib/libart.so (MterpInvokeVirtual+1148) #00 pc 00000000000d2814 /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_virtual+20) #00 pc 000000000002c992 /data/user_de/0/com.google.android.gms/app_chimera/m/0000005f/MeasurementDynamite.apk (lp.run+78) #00 pc 0000000000424aa9 /apex/com.android.runtime/lib/libart.so (MterpInvokeInterface+1432) #00 pc 00000000000d2a14 /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_interface+20) #00 pc 000000000002e2b2 /data/user_de/0/com.google.android.gms/app_chimera/m/0000005f/MeasurementDynamite.apk (ma.C+18) #00 pc 00000000001ebf0d /apex/com.android.runtime/lib/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.65484028430099480)+192) #00 pc 00000000001f06f1 /apex/com.android.runtime/lib/libart.so (art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*)+124) #00 pc 0000000000417c59 /apex/com.android.runtime/lib/libart.so (artQuickToInterpreterBridge+808) #00 pc 00000000000dc5a1 /apex/com.android.runtime/lib/libart.so (art_quick_to_interpreter_bridge+32) #00 pc 000000000205942f /memfd:/jit-cache (kn.T+6254) #00 pc 00000000000d7bc5 /apex/com.android.runtime/lib/libart.so (art_quick_invoke_stub_internal+68) #00 pc 000000000042e0e7 /apex/com.android.runtime/lib/libart.so (art_quick_invoke_stub+250)
内容的提问来源于stack exchange,提问作者faisal ur rehman
相关产品推荐
相关产品推荐

