bytedance / bhook

:fire: ByteHook is an Android PLT hook library which supports armeabi-v7a, arm64-v8a, x86 and x86_64.
https://github.com/bytedance/bhook/tree/main/doc#readme
MIT License
2.05k stars 315 forks source link

bh_elf_tree操作时crash #19

Closed flx413 closed 2 years ago

flx413 commented 2 years ago

机型:Android 8.1.0/9/11 Redmi 5 Plus/Redmi K40/Mi 10S/Redmi K30/Redmi 6 Pro cpuArch:arm64-v8a bhook版本:1.0.3

#00 pc 000000000001d09c /system/lib64/libc.so (strcmp+28)
#01 pc 00000000000073b4 /data/app/==/lib/arm64/libbytehook.so  (bytehook/src/main/cpp/bh_elf_manager.c:53)
#02 pc 0000000000006fac /data/app/==/lib/arm64/libbytehook.so  (bytehook/src/main/cpp/bh_elf_manager.c:96)
#03 pc 00000000000098b8 /system/bin/linker64 (__dl__Z18do_dl_iterate_phdrPFiP12dl_phdr_infomPvES1_+76)
#04 pc 00000000000092dc /system/bin/linker64 (__dl_dl_iterate_phdr+48)
#05 pc 00000000000011cc /system/lib64/libdl.so (dl_iterate_phdr+8)
(bytehook/src/main/cpp/bh_dl_iterate.c:83)
(bytehook/src/main/cpp/bh_dl_iterate.c:156)
#06 pc 0000000000006ab4 /data/app/==/lib/arm64/libbytehook.so  (bytehook/src/main/cpp/bh_elf_manager.c:132)
#07 pc 0000000000005714 /data/app/==/lib/arm64/libbytehook.so
#08 pc 00000000000011b8 /system/lib64/libdl.so (dlclose+8)
......
#14 pc 0000000000067e50 /system/lib64/libc.so (_ZL15__pthread_startPv+36)
#15 pc 000000000001f280 /system/lib64/libc.so (__start_thread+68)

是在每次dlopen/dlclose的时候刷新elf tree缓存,遍历elf的时候挂了...崩溃的位置在 bh_elf_tree_RB_FIND、bh_elf_tree_RB_NEXT,应该都是同一个问题。 看log好像都是APP在后台发生的

caikelun commented 2 years ago

@flx413 从源码没看出问题在哪里。能复线的话调试一下?或者提供下tombstone/coredump?