HarmonyOS 鸿蒙调用 so 出现这种报错该怎么排查?
HarmonyOS 鸿蒙调用 so 出现这种报错该怎么排查?
Build info:ALN-AL80 5.0.0.26(SP8DEVC00E29R4P6log)
Fingerprint:e9c9f566a25db01e4eae1c2341d050c474f175ab773e50dea73500b42906d44b
Module name:com.xq.crea
Version:1.0.0
VersionCode:1000000
PreInstalled:No
Foreground:No
Timestamp:2024-08-06 16:43:41.642
Pid:51803
Uid:20020158
Process name:com.xq.crea
Process life time:11s
Reason:Signal:SIGSEGV(SEGV_MAPERR)@000000000000000000 probably caused by NULL pointer dereference
Fault thread info:
Tid:51803, Name:.xq.crea
#00 pc 0000000000000000 Not mapped
#01 pc 0000000000015324 /system/lib64/chipset-pub-sdk/libeventhandler.z.so(OHOS::AppExecFwk::EventHandler::DistributeEvent(std::_h::unique_ptr<OHOS::AppExecFwk::InnerEvent, void ()(OHOS::AppExecFwk::InnerEvent)> const&)+1156)(6343d6e2f0c1d0e7b18ab44b76f24219)
#02 pc 0000000000023f78 /system/lib64/chipset-pub-sdk/libeventhandler.z.so(OHOS::AppExecFwk::(anonymous namespace)::EventRunnerImpl::ExecuteEventHandler(std::h::unique_ptr<OHOS::AppExecFwk::InnerEvent, void ()(OHOS::AppExecFwk::InnerEvent)>&)+340)(6343d6e2f0c1d0e7b18ab44b76f24219)
#03 pc 0000000000023850 /system/lib64/chipset-pub-sdk/libeventhandler.z.so(OHOS::AppExecFwk::(anonymous namespace)::EventRunnerImpl::Run()+872)(6343d6e2f0c1d0e7b18ab44b76f24219)
#04 pc 0000000000026628 /system/lib64/chipset-pub-sdk/libeventhandler.z.so(OHOS::AppExecFwk::EventRunner::Run()+284)(6343d6e2f0c1d0e7b18ab44b76f24219)
#05 pc 00000000000a5e68 /system/lib64/platformsdk/libappkit_native.z.so(OHOS::AppExecFwk::MainThread::Start()+764)(09725aa629f5e40fe66502a73142e907)
#06 pc 0000000000004880 /system/lib64/appspawn/appspawn/libappspawn_ace.z.so(RunChildProcessor(AppSpawnContent*, AppSpawnClient*)+216)(220bc1cc3deab5ad036f941acb686439)
#07 pc 0000000000008788 /system/bin/appspawn(AppSpawnChild+404)(b2257094872d9fd8bf42cb426827c3fd)
#08 pc 00000000000084c8 /system/bin/appspawn(AppSpawnProcessMsg+636)(b2257094872d9fd8bf42cb426827c3fd)
#09 pc 000000000000f974 /system/bin/appspawn(ProcessSpawnReqMsg+228)(b2257094872d9fd8bf42cb426827c3fd)
#10 pc 000000000000f224 /system/bin/appspawn(OnReceiveRequest+172)(b2257094872d9fd8bf42cb426827c3fd)
#11 pc 0000000000017c9c /system/lib64/chipset-pub-sdk/libbegetutil.z.so(HandleRecvMsg+260)(e0ae01bc83cc4d60d93c1d91c4fa6f0f)
#12 pc 00000000000177bc /system/lib64/chipset-pub-sdk/libbegetutil.z.so(HandleStreamEvent+168)(e0ae01bc83cc4d60d93c1d91c4fa6f0f)
#13 pc 0000000000014ee0 /system/lib64/chipset-pub-sdk/libbegetutil.z.so(ProcessEvent+108)(e0ae01bc83cc4d60d93c1d91c4fa6f0f)
#14 pc 0000000000014aa0 /system/lib64/chipset-pub-sdk/libbegetutil.z.so(RunLoop+356)(e0ae01bc83cc4d60d93c1d91c4fa6f0f)
#15 pc 000000000000d3bc /system/bin/appspawn(AppSpawnRun+136)(b2257094872d9fd8bf42cb426827c3fd)
#16 pc 000000000000ad20 /system/bin/appspawn(main+708)(b2257094872d9fd8bf42cb426827c3fd)
#17 pc 000000000009eb0c /system/lib/ld-musl-aarch64.so.1(libc_start_main_stage2+64)(5eee310927fa497814a95d97820a89bb)
Registers:
x0:0000005978c4c880 x1:000000596534a614 x2:000000000000000c x3:2f2e2e0072656c64
x4:000000596534a620 x5:0000007f07172fb5 x6:6e6148746e657645 x7:72656c646e614874
x8:0000000000000000 x9:3aa536b17fc6fa1f x10:000000003b9aca00 x11:c9d0cdd3f0f9001e
x12:00000182072b18b9 x13:000000000fa12167 x14:0000000025025c6b x15:0000000000000000
x16:0000005961920968 x17:00000059615d0b6c x18:ffff000000000006 x19:0000005978c08ca0
x20:0000007f07173268 x21:00000059653701d0 x22:0000000000000001 x23:0000005965370270
x24:00000059653701f0 x25:0000000000000000 x26:0000000000000000 x27:000000562d23f334
x28:0000005961c5ac08 x29:0000007f071730e0
lr:0000005965355328 sp:0000007f07173000 pc:0000000000000000
根据日志信息,可以看出是一个空指针引用错误(NULL pointer dereference),可能是因为应用程序访问了一个空指针对象或者已经被释放的对象。
针对HarmonyOS调用so库出现报错的问题,排查步骤如下:
- 检查模块名称与so文件名称一致性:确保模块名与so文件名(如libxxx.so)匹配,且napi_module中nm_modname字段正确。
- 查看日志:过滤模块加载相关日志,搜索"dlopen"关键字,检查是否有权限不足、依赖so加载失败或路径错误等报错。
- 确认so文件路径:检查so文件是否已正确放置在应用的libs目录下,并确保路径配置正确。
- 检查so文件依赖:确认所有依赖的so文件都已正确打包到应用中,并有权限访问。
如果问题依旧没法解决,请加我微信,我的微信是itying888。