Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

大佬,我试了一下发现不能在子线程解码,这是为啥呀? #2

Closed
beginnersun opened this issue Jun 8, 2020 · 17 comments
Labels
bug Something isn't working

Comments

@beginnersun
Copy link

No description provided.

@WuFengXue
Copy link
Owner

刚刚改到子线程编解码验证了一下,确实会闪退

@WuFengXue WuFengXue added the bug Something isn't working label Jun 9, 2020
@beginnersun
Copy link
Author

是so库的问题么?

@WuFengXue
Copy link
Owner

在子线程中,lame 库会崩溃(对应源码传送门),崩溃信息如下:

06-09 11:18:59.828 16514-16718/com.reinhard.wechat.voicecodec A/libc: Fatal signal 11 (SIGSEGV) at 0x7895a000 (code=2), thread 16718 (Thread-328) 06-09 11:18:59.928 176-176/? I/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 06-09 11:18:59.928 176-176/? I/DEBUG: Build fingerprint: 'google/hammerhead/hammerhead:4.4/KRT16M/893803:user/release-keys' 06-09 11:18:59.928 176-176/? I/DEBUG: Revision: '11' 06-09 11:18:59.928 176-176/? I/DEBUG: pid: 16514, tid: 16718, name: Thread-328 >>> com.reinhard.wechat.voicecodec <<< 06-09 11:18:59.928 176-176/? I/DEBUG: signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 7895a000 06-09 11:18:59.998 176-176/? I/DEBUG: r0 78959fe8 r1 00000000 r2 000325e8 r3 000c80c8 06-09 11:18:59.998 176-176/? I/DEBUG: r4 78ae157c r5 777e8540 r6 00000004 r7 78a57a08 06-09 11:18:59.998 176-176/? I/DEBUG: r8 78a57ae4 r9 7777bfa0 sl 777e8550 fp 78a57afc 06-09 11:18:59.998 176-176/? I/DEBUG: ip 78ae1838 sp 788c416c lr 78a8874f pc 400a90f4 cpsr 200f0010 06-09 11:18:59.998 176-176/? I/DEBUG: d0 0000000000000000 d1 0000000000000000 06-09 11:18:59.998 176-176/? I/DEBUG: d2 0000000000000000 d3 0000000000000000 06-09 11:18:59.998 176-176/? I/DEBUG: d4 3fe0000000004cb8 d5 3fdfffffffff668f 06-09 11:18:59.998 176-176/? I/DEBUG: d6 0000000000000000 d7 3ce3a3f58598a5bf 06-09 11:18:59.998 176-176/? I/DEBUG: d8 0000000000000000 d9 0000000000000000 06-09 11:18:59.998 176-176/? I/DEBUG: d10 0000000000000000 d11 0000000000000000 06-09 11:18:59.998 176-176/? I/DEBUG: d12 0000000000000000 d13 0000000000000000 06-09 11:18:59.998 176-176/? I/DEBUG: d14 0000000000000000 d15 0000000000000000 06-09 11:18:59.998 176-176/? I/DEBUG: d16 3fbdc47711dc5400 d17 3fbdc47711dc5400 06-09 11:18:59.998 176-176/? I/DEBUG: d18 408f400000000000 d19 4059000000000000 06-09 11:18:59.998 176-176/? I/DEBUG: d20 400367381d7dbf48 d21 3ff68fd6166296fb 06-09 11:18:59.998 176-176/? I/DEBUG: d22 3fe1da1300000000 d23 400367381d7dbf48 06-09 11:18:59.998 176-176/? I/DEBUG: d24 0018001700150016 d25 0019001a001a0019 06-09 11:18:59.998 176-176/? I/DEBUG: d26 0000000000000000 d27 400367381d7dbf48 06-09 11:18:59.998 176-176/? I/DEBUG: d28 3ff0000000000000 d29 0000000000000000 06-09 11:18:59.998 176-176/? I/DEBUG: d30 001a001a001a001a d31 4000000000000000 06-09 11:18:59.998 176-176/? I/DEBUG: scr 20000012 06-09 11:18:59.998 176-176/? I/DEBUG: backtrace: 06-09 11:18:59.998 176-176/? I/DEBUG: #00 pc 000220f4 /system/lib/libc.so (memset+24) 06-09 11:18:59.998 176-176/? I/DEBUG: #01 pc 0003074b /data/app-lib/com.reinhard.wechat.voicecodec-2/libwcvcodec.so (lame_main+374) 06-09 11:18:59.998 176-176/? I/DEBUG: stack: 06-09 11:18:59.998 176-176/? I/DEBUG: ........ ........ 06-09 11:18:59.998 176-176/? I/DEBUG: memory near r0: 06-09 11:18:59.998 176-176/? I/DEBUG: 78959fc8 ffffffff ffffffff ffffffff ffffffff 06-09 11:18:59.998 176-176/? I/DEBUG: 78959fd8 ffffffff ffffffff ffffffff ffffffff 06-09 11:18:59.998 176-176/? I/DEBUG: 78959fe8 ffffffff ffffffff ffffffff ffffffff 06-09 11:18:59.998 176-176/? I/DEBUG: 78959ff8 ffffffff ffffffff 00000000 00000000 06-09 11:18:59.998 176-176/? I/DEBUG: 7895a008 00000000 00000000 00000000 00000000 06-09 11:18:59.998 176-176/? I/DEBUG: 7895a018 00000000 00000000 00000000 00000000 06-09 11:18:59.998 176-176/? I/DEBUG: 7895a028 00000000 00000000 00000000 00000000 06-09 11:18:59.998 176-176/? I/DEBUG: 7895a038 00000000 00000000 00000000 00000000 06-09 11:18:59.998 176-176/? I/DEBUG: 7895a048 00000000 00000000 00000000 00000000 06-09 11:18:59.998 176-176/? I/DEBUG: 7895a058 00000000 00000000 00000000 00000000 06-09 11:18:59.998 176-176/? I/DEBUG: 7895a068 00000000 00000000 00000000 00000000 06-09 11:18:59.998 176-176/? I/DEBUG: 7895a078 00000000 00000000 00000000 00000000 06-09 11:18:59.998 176-176/? I/DEBUG: 7895a088 00000000 00000000 00000000 00000000 06-09 11:18:59.998 176-176/? I/DEBUG: 7895a098 00000000 00000000 00000000 00000000 06-09 11:18:59.998 176-176/? I/DEBUG: 7895a0a8 00000000 00000000 00000000 00000000 06-09 11:18:59.998 176-176/? I/DEBUG: 7895a0b8 00000000 00000000 00000000 00000000 06-09 11:18:59.998 176-176/? I/DEBUG: memory near r2: 06-09 11:18:59.998 176-176/? I/DEBUG: 000325c8 ffffffff ffffffff ffffffff ffffffff 06-09 11:18:59.998 176-176/? I/DEBUG: 000325d8 ffffffff ffffffff ffffffff ffffffff 06-09 11:18:59.998 176-176/? I/DEBUG: 000325e8 ffffffff ffffffff ffffffff ffffffff 06-09 11:18:59.998 176-176/? I/DEBUG: 000325f8 ffffffff ffffffff ffffffff ffffffff 06-09 11:18:59.998 176-176/? I/DEBUG: 00032608 ffffffff ffffffff ffffffff ffffffff 06-09 11:18:59.998 176-176/? I/DEBUG: 00032618 ffffffff ffffffff ffffffff ffffffff 06-09 11:18:59.998 176-176/? I/DEBUG: 00032628 ffffffff ffffffff ffffffff ffffffff 06-09 11:18:59.998 176-176/? I/DEBUG: 00032638 ffffffff ffffffff ffffffff ffffffff 06-09 11:18:59.998 176-176/? I/DEBUG: 00032648 ffffffff ffffffff ffffffff ffffffff 06-09 11:18:59.998 176-176/? I/DEBUG: 00032658 ffffffff ffffffff ffffffff ffffffff 06-09 11:18:59.998 176-176/? I/DEBUG: 00032668 ffffffff ffffffff ffffffff ffffffff 06-09 11:18:59.998 176-176/? I/DEBUG: 00032678 ffffffff ffffffff ffffffff ffffffff 06-09 11:18:59.998 176-176/? I/DEBUG: 00032688 ffffffff ffffffff ffffffff ffffffff 06-09 11:18:59.998 176-176/? I/DEBUG: 00032698 ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.008 176-176/? I/DEBUG: 000326a8 ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.008 176-176/? I/DEBUG: 000326b8 ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.008 176-176/? I/DEBUG: memory near r3: 06-09 11:19:00.008 176-176/? I/DEBUG: 000c80a8 ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.008 176-176/? I/DEBUG: 000c80b8 ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.008 176-176/? I/DEBUG: 000c80c8 ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.008 176-176/? I/DEBUG: 000c80d8 ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.008 176-176/? I/DEBUG: 000c80e8 ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.008 176-176/? I/DEBUG: 000c80f8 ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.008 176-176/? I/DEBUG: 000c8108 ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.008 176-176/? I/DEBUG: 000c8118 ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.008 176-176/? I/DEBUG: 000c8128 ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.008 176-176/? I/DEBUG: 000c8138 ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.008 176-176/? I/DEBUG: 000c8148 ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.008 176-176/? I/DEBUG: 000c8158 ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.008 176-176/? I/DEBUG: 000c8168 ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.008 176-176/? I/DEBUG: 000c8178 ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.008 176-176/? I/DEBUG: 000c8188 ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.008 176-176/? I/DEBUG: 000c8198 ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.008 176-176/? I/DEBUG: memory near r4: 06-09 11:19:00.008 176-176/? I/DEBUG: 78ae155c 00000000 00000000 00000000 00000000 06-09 11:19:00.008 176-176/? I/DEBUG: 78ae156c 00000000 00000000 00000000 00000000 06-09 11:19:00.008 176-176/? I/DEBUG: 78ae157c 400d5384 78ad1024 78ad6030 78ad606c 06-09 11:19:00.008 176-176/? I/DEBUG: 78ae158c 78ad6028 78ad6020 78ad6f7a 78ae0bdc 06-09 11:19:00.008 176-176/? I/DEBUG: 78ae159c 78ae0d0c 78ae0c94 78ae0dc4 78ad5ebc 06-09 11:19:00.008 176-176/? I/DEBUG: 78ae15ac 78ad5edc 78ad5efc 78ad5f1c 78ad5f3c 06-09 11:19:00.008 176-176/? I/DEBUG: 78ae15bc 78ad5fec 78ad5fe0 78ad5fd0 78ad6fcc 06-09 11:19:00.008 176-176/? I/DEBUG: 78ae15cc 78ad6fc2 78ad6fd0 78ad5d54 78ad5e58 06-09 11:19:00.008 176-176/? I/DEBUG: 78ae15dc 78ad5eb8 78ad5e5c 78ad5ffc 78ad5ff0 06-09 11:19:00.008 176-176/? I/DEBUG: 78ae15ec 78ad6198 78ad6094 78ad633c 78ad61b8 06-09 11:19:00.008 176-176/? I/DEBUG: 78ae15fc 78ad6544 78ad6340 78ad684c 78ad6548 06-09 11:19:00.008 176-176/? I/DEBUG: 78ae160c 78ad61b4 78ad619c 78ad6898 78ad6850 06-09 11:19:00.008 176-176/? I/DEBUG: 78ae161c 78ad18b8 78ad18b0 78ae0b70 78ae0b58 06-09 11:19:00.008 176-176/? I/DEBUG: 78ae162c 78ad1950 78ad5fc0 78ad5fb8 78ad601c 06-09 11:19:00.008 176-176/? I/DEBUG: 78ae163c 78ad6010 78ad5fcc 78ad5fc4 78ad600c 06-09 11:19:00.008 176-176/? I/DEBUG: 78ae164c 78ad6000 78ad1262 78ad12ba 78ad6bf0 06-09 11:19:00.008 176-176/? I/DEBUG: memory near r5: 06-09 11:19:00.008 176-176/? I/DEBUG: 777e8520 00000000 00000000 00000000 00000000 06-09 11:19:00.008 176-176/? I/DEBUG: 777e8530 00000000 00000000 00000000 0000045b 06-09 11:19:00.008 176-176/? I/DEBUG: 777e8540 6e78ff90 7777bfa0 6da4c250 7580a000 06-09 11:19:00.008 176-176/? I/DEBUG: 777e8550 00000000 00000000 78a57c40 00000000 06-09 11:19:00.008 176-176/? I/DEBUG: 777e8560 78a57c94 0000000c 00000000 414afd40 06-09 11:19:00.008 176-176/? I/DEBUG: 777e8570 00000000 00000000 40d2d870 77778300 06-09 11:19:00.008 176-176/? I/DEBUG: 777e8580 00000000 00000000 00000001 00004000 06-09 11:19:00.008 176-176/? I/DEBUG: 777e8590 00000000 777635f0 414afd40 414b4c00 06-09 11:19:00.008 176-176/? I/DEBUG: 777e85a0 00000000 414b8cfc 414b8d70 414b8c20 06-09 11:19:00.008 176-176/? I/DEBUG: 777e85b0 414b8c40 414b8c9c 00000000 00000000 06-09 11:19:00.008 176-176/? I/DEBUG: 777e85c0 777ea858 00000028 00000000 00000000 06-09 11:19:00.008 176-176/? I/DEBUG: 777e85d0 00000000 00000000 00002000 4154191c 06-09 11:19:00.008 176-176/? I/DEBUG: 777e85e0 00000000 00000000 00000004 774a5c38 06-09 11:19:00.008 176-176/? I/DEBUG: 777e85f0 00000001 00000040 00000200 00000000 06-09 11:19:00.008 176-176/? I/DEBUG: 777e8600 00000000 00000000 00000000 00000000 06-09 11:19:00.008 176-176/? I/DEBUG: 777e8610 00000000 00000000 411cb888 00000000 06-09 11:19:00.008 176-176/? I/DEBUG: memory near r7: 06-09 11:19:00.008 176-176/? I/DEBUG: 78a579e8 00000000 00000000 00000000 00000000 06-09 11:19:00.008 176-176/? I/DEBUG: 78a579f8 00000000 2008da71 78ae157c 00000004 06-09 11:19:00.008 176-176/? I/DEBUG: 78a57a08 78a57a28 78ac2acd 00000000 00000000 06-09 11:19:00.008 176-176/? I/DEBUG: 78a57a18 00000000 776d9cd8 78a57a80 0000000e 06-09 11:19:00.008 176-176/? I/DEBUG: 78a57a28 78a57a38 78ac2a8b 78a57a80 0000000e 06-09 11:19:00.008 176-176/? I/DEBUG: 78a57a38 78a57ad8 78a66647 78a57b98 414dd4d5 06-09 11:19:00.008 176-176/? I/DEBUG: 78a57a48 414dd4d5 00000000 1d20000d 414dd4d5 06-09 11:19:00.008 176-176/? I/DEBUG: 78a57a58 0000000e 00000005 774a89e8 777ebfa0 06-09 11:19:00.008 176-176/? I/DEBUG: 78a57a68 777ebf80 1d500009 1d600005 1d600001 06-09 11:19:00.008 176-176/? I/DEBUG: 78a57a78 774a8ea8 00000000 78ac66b1 78ac66b8 06-09 11:19:00.008 176-176/? I/DEBUG: 78a57a88 78ac66bb 78ac66bd 78ac66c0 78ac66c4 06-09 11:19:00.008 176-176/? I/DEBUG: 78a57a98 78ac66c7 78ac66c9 78ac66cc 78ac66cf 06-09 11:19:00.008 176-176/? I/DEBUG: 78a57aa8 78ac66d5 78ac66cf 777ebfa0 774a89e8 06-09 11:19:00.008 176-176/? I/DEBUG: 78a57ab8 78ac6698 777ebf80 777ebfa0 78ac66a2 06-09 11:19:00.008 176-176/? I/DEBUG: 78a57ac8 78ac66aa 2008da71 6da4c350 00000004 06-09 11:19:00.008 176-176/? I/DEBUG: 78a57ad8 7777bfac 414afbd0 1d20000d 414db111 06-09 11:19:00.008 176-176/? I/DEBUG: memory near r8: 06-09 11:19:00.008 176-176/? I/DEBUG: 78a57ac4 78ac66a2 78ac66aa 2008da71 6da4c350 06-09 11:19:00.008 176-176/? I/DEBUG: 78a57ad4 00000004 7777bfac 414afbd0 1d20000d 06-09 11:19:00.008 176-176/? I/DEBUG: 78a57ae4 414db111 7777bfa0 00000001 7584a517 06-09 11:19:00.008 176-176/? I/DEBUG: 78a57af4 42dd7cc8 42dd7688 414e0127 7777bfa0 06-09 11:19:00.008 176-176/? I/DEBUG: 78a57b04 7584a513 78a66555 777e8550 777ebfaa 06-09 11:19:00.008 176-176/? I/DEBUG: 78a57b14 77763940 1d600001 00000000 774a89e8 06-09 11:19:00.008 176-176/? I/DEBUG: 78a57b24 400d5384 78a66555 40098257 400d1000 06-09 11:19:00.008 176-176/? I/DEBUG: 78a57b34 777ebf80 00000000 774a89e8 00000000 06-09 11:19:00.008 176-176/? I/DEBUG: 78a57b44 40094c0d 76168370 414e1d57 7777bfc0 06-09 11:19:00.008 176-176/? I/DEBUG: 78a57b54 42dd7cc8 777e8540 00000000 42dd7cc8 06-09 11:19:00.008 176-176/? I/DEBUG: 78a57b64 414fdc85 42dd7cc8 42d6db10 777e8540 06-09 11:19:00.008 176-176/? I/DEBUG: 78a57b74 40094c0d 77498190 414fd705 00000000 06-09 11:19:00.008 176-176/? I/DEBUG: 78a57b84 00000000 78a57bf4 6da4c364 00000001 06-09 11:19:00.008 176-176/? I/DEBUG: 78a57b94 42dd7cc8 00000000 00000007 6da4c350 06-09 11:19:00.008 176-176/? I/DEBUG: 78a57ba4 7584e550 78a57bf4 00000038 00000001 06-09 11:19:00.008 176-176/? I/DEBUG: 78a57bb4 414fde3b 7584e550 75825430 42dd7cc8 06-09 11:19:00.008 176-176/? I/DEBUG: memory near r9: 06-09 11:19:00.008 176-176/? I/DEBUG: 7777bf80 7777bfac 00000000 6da4c2e0 7777bfc0 06-09 11:19:00.008 176-176/? I/DEBUG: 7777bf90 7583fcf0 6da4c350 00000000 00000000 06-09 11:19:00.008 176-176/? I/DEBUG: 7777bfa0 1d600005 1d500009 1d20000d 7777bfe4 06-09 11:19:00.008 176-176/? I/DEBUG: 7777bfb0 6e78ff9c 6da4c250 7583fcf0 00000000 06-09 11:19:00.008 176-176/? I/DEBUG: 7777bfc0 42dd74f8 42dd7560 42dd75c8 42dd7a08 06-09 11:19:00.018 176-176/? I/DEBUG: 7777bfd0 7777c000 00000000 6d6f3eb0 6e78ff9c 06-09 11:19:00.018 176-176/? I/DEBUG: 7777bfe0 00000000 42dd7a08 42dd7688 00000000 06-09 11:19:00.018 176-176/? I/DEBUG: 7777bff0 00000000 00000000 00000000 00000000 06-09 11:19:00.018 176-176/? I/DEBUG: 7777c000 ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.018 176-176/? I/DEBUG: 7777c010 ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.018 176-176/? I/DEBUG: 7777c020 ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.018 176-176/? I/DEBUG: 7777c030 ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.018 176-176/? I/DEBUG: 7777c040 ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.018 176-176/? I/DEBUG: 7777c050 ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.018 176-176/? I/DEBUG: 7777c060 ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.018 176-176/? I/DEBUG: 7777c070 ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.018 176-176/? I/DEBUG: memory near sl: 06-09 11:19:00.018 176-176/? I/DEBUG: 777e8530 00000000 00000000 00000000 0000045b 06-09 11:19:00.018 176-176/? I/DEBUG: 777e8540 6e78ff90 7777bfa0 6da4c250 7580a000 06-09 11:19:00.018 176-176/? I/DEBUG: 777e8550 00000000 00000000 78a57c40 00000000 06-09 11:19:00.018 176-176/? I/DEBUG: 777e8560 78a57c94 0000000c 00000000 414afd40 06-09 11:19:00.018 176-176/? I/DEBUG: 777e8570 00000000 00000000 40d2d870 77778300 06-09 11:19:00.018 176-176/? I/DEBUG: 777e8580 00000000 00000000 00000001 00004000 06-09 11:19:00.018 176-176/? I/DEBUG: 777e8590 00000000 777635f0 414afd40 414b4c00 06-09 11:19:00.018 176-176/? I/DEBUG: 777e85a0 00000000 414b8cfc 414b8d70 414b8c20 06-09 11:19:00.018 176-176/? I/DEBUG: 777e85b0 414b8c40 414b8c9c 00000000 00000000 06-09 11:19:00.018 176-176/? I/DEBUG: 777e85c0 777ea858 00000028 00000000 00000000 06-09 11:19:00.018 176-176/? I/DEBUG: 777e85d0 00000000 00000000 00002000 4154191c 06-09 11:19:00.018 176-176/? I/DEBUG: 777e85e0 00000000 00000000 00000004 774a5c38 06-09 11:19:00.018 176-176/? I/DEBUG: 777e85f0 00000001 00000040 00000200 00000000 06-09 11:19:00.018 176-176/? I/DEBUG: 777e8600 00000000 00000000 00000000 00000000 06-09 11:19:00.018 176-176/? I/DEBUG: 777e8610 00000000 00000000 411cb888 00000000 06-09 11:19:00.018 176-176/? I/DEBUG: 777e8620 00000000 00000000 00000000 00000000 06-09 11:19:00.018 176-176/? I/DEBUG: memory near fp: 06-09 11:19:00.018 176-176/? I/DEBUG: 78a57adc 414afbd0 1d20000d 414db111 7777bfa0 06-09 11:19:00.018 176-176/? I/DEBUG: 78a57aec 00000001 7584a517 42dd7cc8 42dd7688 06-09 11:19:00.018 176-176/? I/DEBUG: 78a57afc 414e0127 7777bfa0 7584a513 78a66555 06-09 11:19:00.018 176-176/? I/DEBUG: 78a57b0c 777e8550 777ebfaa 77763940 1d600001 06-09 11:19:00.018 176-176/? I/DEBUG: 78a57b1c 00000000 774a89e8 400d5384 78a66555 06-09 11:19:00.018 176-176/? I/DEBUG: 78a57b2c 40098257 400d1000 777ebf80 00000000 06-09 11:19:00.018 176-176/? I/DEBUG: 78a57b3c 774a89e8 00000000 40094c0d 76168370 06-09 11:19:00.018 176-176/? I/DEBUG: 78a57b4c 414e1d57 7777bfc0 42dd7cc8 777e8540 06-09 11:19:00.018 176-176/? I/DEBUG: 78a57b5c 00000000 42dd7cc8 414fdc85 42dd7cc8 06-09 11:19:00.018 176-176/? I/DEBUG: 78a57b6c 42d6db10 777e8540 40094c0d 77498190 06-09 11:19:00.018 176-176/? I/DEBUG: 78a57b7c 414fd705 00000000 00000000 78a57bf4 06-09 11:19:00.018 176-176/? I/DEBUG: 78a57b8c 6da4c364 00000001 42dd7cc8 00000000 06-09 11:19:00.018 176-176/? I/DEBUG: 78a57b9c 00000007 6da4c350 7584e550 78a57bf4 06-09 11:19:00.018 176-176/? I/DEBUG: 78a57bac 00000038 00000001 414fde3b 7584e550 06-09 11:19:00.018 176-176/? I/DEBUG: 78a57bbc 75825430 42dd7cc8 7584e550 7580a000 06-09 11:19:00.018 176-176/? I/DEBUG: 78a57bcc 6da4c350 42dd7cc8 2008da71 00000008 06-09 11:19:00.018 176-176/? I/DEBUG: memory near ip: 06-09 11:19:00.018 176-176/? I/DEBUG: 78ae1818 78a66d81 400aa09d 400c1195 400a8fc5 06-09 11:19:00.018 176-176/? I/DEBUG: 78ae1828 400c1191 78a68fb1 78a67d01 78a67a2d 06-09 11:19:00.018 176-176/? I/DEBUG: 78ae1838 400a90b0 400c1199 78a78a61 78a78c29 06-09 11:19:00.018 176-176/? I/DEBUG: 78ae1848 78a6f945 78a80ead 78a68c31 78a67539 06-09 11:19:00.018 176-176/? I/DEBUG: 78ae1858 78a70775 78a69bf9 78a69865 78a817a5 06-09 11:19:00.018 176-176/? I/DEBUG: 78ae1868 78a69061 78a69931 78a81aed 78a68951 06-09 11:19:00.018 176-176/? I/DEBUG: 78ae1878 78a6d41d 78a6d4a5 78a6ddb9 78a81b75 06-09 11:19:00.018 176-176/? I/DEBUG: 78ae1888 78a6f1e9 78a6eb9b 78a787f5 78a787b5 06-09 11:19:00.018 176-176/? I/DEBUG: 78ae1898 78a7d191 78a7d2f1 78a70a11 78a7d901 06-09 11:19:00.018 176-176/? I/DEBUG: 78ae18a8 78a7e101 78a67505 78a74479 78a72041 06-09 11:19:00.018 176-176/? I/DEBUG: 78ae18b8 78a73821 78a7d543 78a73a41 78a73309 06-09 11:19:00.018 176-176/? I/DEBUG: 78ae18c8 78a72809 78a6d435 78a6e1ad 78a66df5 06-09 11:19:00.018 176-176/? I/DEBUG: 78ae18d8 78a6f82d 78a7868d 78a7d4c9 78a74159 06-09 11:19:00.018 176-176/? I/DEBUG: 78ae18e8 78a741f9 78a7d5d9 78a7d765 78a80c41 06-09 11:19:00.018 176-176/? I/DEBUG: 78ae18f8 78a7094d 78a78715 78a748db 78a70e09 06-09 11:19:00.018 176-176/? I/DEBUG: 78ae1908 78a7471d 78a74e2d 78a6e671 78a67291 06-09 11:19:00.018 176-176/? I/DEBUG: memory near sp: 06-09 11:19:00.018 176-176/? I/DEBUG: 788c414c ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.018 176-176/? I/DEBUG: 788c415c ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.018 176-176/? I/DEBUG: 788c416c ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.018 176-176/? I/DEBUG: 788c417c ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.018 176-176/? I/DEBUG: 788c418c ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.018 176-176/? I/DEBUG: 788c419c ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.018 176-176/? I/DEBUG: 788c41ac ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.018 176-176/? I/DEBUG: 788c41bc ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.018 176-176/? I/DEBUG: 788c41cc ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.018 176-176/? I/DEBUG: 788c41dc ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.018 176-176/? I/DEBUG: 788c41ec ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.018 176-176/? I/DEBUG: 788c41fc ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.018 176-176/? I/DEBUG: 788c420c ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.018 176-176/? I/DEBUG: 788c421c ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.028 176-176/? I/DEBUG: 788c422c ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.028 176-176/? I/DEBUG: 788c423c ffffffff ffffffff ffffffff ffffffff 06-09 11:19:00.028 176-176/? I/DEBUG: code around pc: 06-09 11:19:00.028 176-176/? I/DEBUG: 400a90d4 e1a02001 e3a01000 e92d0001 eee01b10 06-09 11:19:00.028 176-176/? I/DEBUG: 400a90e4 e2522020 3a000003 f2202150 e2522020 06-09 11:19:00.028 176-176/? I/DEBUG: 400a90f4 f400020d 2afffffc e2822020 e3120010 06-09 11:19:00.028 176-176/? I/DEBUG: 400a9104 0a000000 f4000a0d e1b0ce82 3a000000 06-09 11:19:00.028 176-176/? I/DEBUG: 400a9114 f400070d aa000000 f480080d e1b0cf82 06-09 11:19:00.028 176-176/? I/DEBUG: 400a9124 44c01001 24c01001 24c01001 e8bd0001 06-09 11:19:00.028 176-176/? I/DEBUG: 400a9134 e12fff1e f5d0f000 f5d1f000 e180c001 06-09 11:19:00.028 176-176/? I/DEBUG: 400a9144 e31c0007 1a000013 e25dd010 e1cd40f8 06-09 11:19:00.028 176-176/? I/DEBUG: 400a9154 e1cd60f0 e3e06000 e3a07000 f5d0f010 06-09 11:19:00.028 176-176/? I/DEBUG: 400a9164 f5d1f010 e0c020d8 e0c140d8 e1520004 06-09 11:19:00.028 176-176/? I/DEBUG: 400a9174 e652cf96 e687cfb6 035c0000 1a000072 06-09 11:19:00.028 176-176/? I/DEBUG: 400a9184 e1530005 e653cf96 e687cfb6 035c0000 06-09 11:19:00.028 176-176/? I/DEBUG: 400a9194 1a00006a eafffff0 e210c003 0a000018 06-09 11:19:00.028 176-176/? I/DEBUG: 400a91a4 e3c00003 e4902004 e1b0cf8c 0a000006 06-09 11:19:00.028 176-176/? I/DEBUG: 400a91b4 2a00000b e4d1c001 e6ef3472 e053c00c 06-09 11:19:00.028 176-176/? I/DEBUG: 400a91c4 1a00000d e3530000 0a00000b e4d1c001 06-09 11:19:00.028 176-176/? I/DEBUG: code around lr: 06-09 11:19:00.028 176-176/? I/DEBUG: 78a8872c 21009029 90279128 90269829 30019826 06-09 11:19:00.028 176-176/? I/DEBUG: 78a8873c d0082800 982ae7ff 9a279928 f7dc9b26 06-09 11:19:00.028 176-176/? I/DEBUG: 78a8874c 902beb36 982ae009 20a0f89d 900c9927 06-09 11:19:00.028 176-176/? I/DEBUG: 78a8875c eb32f7dc 902b980c 2000e7ff e7ff902c 06-09 11:19:00.028 176-176/? I/DEBUG: 78a8876c 28c7982c e7ffdc0d eb00982c aaf63100 06-09 11:19:00.028 176-176/? I/DEBUG: 78a8877c aa2e4411 1020f842 982ce7ff 902c3001 06-09 11:19:00.028 176-176/? I/DEBUG: 78a8878c 9818e7ee 9a169917 f10d466b f8c30cb4 06-09 11:19:00.028 176-176/? I/DEBUG: 78a8879c f50dc008 f50e6e94 f8c32c48 f641c004 06-09 11:19:00.028 176-176/? I/DEBUG: 78a887ac 44ee0e8a 1cc8f50e c000f8c3 6e08f50d 06-09 11:19:00.028 176-176/? I/DEBUG: 78a887bc 0e0bf10e 13c9f50e ef72f7dc 98149014 06-09 11:19:00.028 176-176/? I/DEBUG: 78a887cc 3ffff1b0 e7ffdc08 f06f9814 1a400101 06-09 11:19:00.028 176-176/? I/DEBUG: 78a887dc 2001bf18 e1739019 447848c3 ed906800 06-09 11:19:00.028 176-176/? I/DEBUG: 78a887ec eef70a03 eef50ac0 eef10bc0 d507fa10 06-09 11:19:00.028 176-176/? I/DEBUG: 78a887fc 48bee7ff 68004478 4180f04f e7ff60c1 06-09 11:19:00.028 176-176/? I/DEBUG: 78a8880c 1ec8f50d 5e80f50e 088af89e d01c2800 06-09 11:19:00.028 176-176/? I/DEBUG: 78a8881c 982de7ff db182801 f50de7ff f10e6e08 06-09 11:19:00.028 176-176/? I/DEBUG: memory map around fault addr 7895a000: 06-09 11:19:00.028 176-176/? I/DEBUG: 7817a000-7895a000 rw- anon_inode:dmabuf 06-09 11:19:00.028 176-176/? I/DEBUG: 7895a000-7895b000 --- 06-09 11:19:00.028 176-176/? I/DEBUG: 7895b000-78a58000 rw-

@WuFengXue
Copy link
Owner

tombstone_03.txt

@beginnersun
Copy link
Author

所以,需要重新编译lame库然后整合进去么?

@WuFengXue
Copy link
Owner

出现问题时的代码抽取如下:

`// lame_main.c
//
// PATH_MAX 的宏定义在 limits.h
// #define PATH_MAX 4096
//
int
lame_main(lame_t gf, int argc, char *argv)
{
char inPath[PATH_MAX + 1];
char outPath[PATH_MAX + 1];
char nogapdir[PATH_MAX + 1];
/
support for "nogap" encoding of up to 200 .wav files */
#define MAX_NOGAP 200
int nogapout = 0;
int max_nogap = MAX_NOGAP;
char nogap_inPath_[MAX_NOGAP][PATH_MAX + 1];
char *nogap_inPath[MAX_NOGAP];
char nogap_outPath_[MAX_NOGAP][PATH_MAX + 1];
char *nogap_outPath[MAX_NOGAP];
……

memset(inPath, 0, sizeof(inPath));
memset(nogap_inPath_, 0, sizeof(nogap_inPath_));
for (i = 0; i < MAX_NOGAP; ++i) {
    nogap_inPath[i] = &nogap_inPath_[i][0];
}
memset(nogap_outPath_, 0, sizeof(nogap_outPath_));
for (i = 0; i < MAX_NOGAP; ++i) {
    nogap_outPath[i] = &nogap_outPath_[i][0];
}

……
return ret;

}`

memset 写的是声明出来的字符数组,照理应该不会引起 SEGV_MAPERR 才对。

@WuFengXue
Copy link
Owner

目前只能够简单的推测子线程方法的内存限制比主线程严格:
lame_main 方法声明的局部变量 nogap_inPath_ 和 nogap_outPath_,各占 200 * 4096 字节 = 800K 的内存

将 MAX_NOGAP 的宏定义中的值,从 200 减少到 20 后,子线程不会报错,可能可以证明这点。

@beginnersun
Copy link
Author

所以内存从800K降到80K就不会报错了么?

@WuFengXue
Copy link
Owner

《[bionic源码解读]Android线程栈大小》 介绍了 android 下的线程栈大小相关的内容,重要结论抽取如下

image

使用 《线程堆栈大小的使用介绍》 的测试代码

// WcvCodec.c

// test code
int print_stack_size() {
    pthread_attr_t attr;
    size_t stack_size = 0;

    int ret = pthread_attr_init(&attr);
    if (ret != 0) {
        LOGE("pthread_attr_init FAILED");
        return JNI_ERR;
    }

    ret = pthread_attr_getstacksize(&attr, &stack_size);
    if (ret != 0) {
        LOGE("pthread_attr_getstacksize FAILED");
    } else {
        LOGE("stack_size = %d Byte, %d k\n", stack_size, stack_size / 1024);
    }
}

/*
 * Class:     com_reinhard_wcvcodec_WcvCodec
 * Method:    decode
 * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I
 */
JNIEXPORT jint JNICALL Java_com_reinhard_wcvcodec_WcvCodec_decode
        (JNIEnv *env, jclass clazz, jstring amrPath, jstring pcmPath, jstring mp3Path) {
    const char *amr = (*env)->GetStringUTFChars(env, amrPath, JNI_FALSE);
    const char *pcm = (*env)->GetStringUTFChars(env, pcmPath, JNI_FALSE);
    const char *mp3 = (*env)->GetStringUTFChars(env, mp3Path, JNI_FALSE);
    int argc = 5;
    const char *argv[] = {"./Decoder", amr, pcm, "-wechat", "-quiet"};

    // test code
    print_stack_size();

    if (silk_decoder_main(argc, (char **) argv) == JNI_OK) {
        int argc2 = 14;
        const char *argv2[] = {"./lame", "-q", "5", "-b", "128", "-m", "m", "-r",
                               "-s", "24000", "--resample", "24000", pcm, mp3};
        return lame_codec_main(argc2, (char **) argv2);
    } else {
        LOGE("silk_decoder_main failed!");
        return JNI_ERR;
    }
}

在安卓4.4(Nexus 5) 的打印如下:

06-09 14:20:48.338 24968-25529/com.reinhard.wechat.voicecodec E/WcvCodec: stack_size = 1040384 Byte, 1016 k

源码中的默认堆栈大小宏定义如下(传送门):

// bionic/libc/bionic/pthread_attr.cpp
#define DEFAULT_THREAD_STACK_SIZE ((1 * 1024 * 1024) - SIGSTKSZ)

在安卓6.0(魅蓝 Note5)的打印如下:

06-09 14:49:58.692 29743-29743/com.reinhard.wechat.voicecodec E/WcvCodec: stack_size = 1040384 Byte, 1016 k

源码中的默认堆栈大小宏定义如下(传送门):

// bionic/libc/bionic/pthread_internal.h
#define PTHREAD_STACK_SIZE_DEFAULT ((1 * 1024 * 1024) - SIGSTKSZ)

@WuFengXue
Copy link
Owner

虽然不同系统版本可能存在差异,但可以确定子线程栈的默认大小差不多就是 1M 左右。

回到我们的问题:

2 * 800k = 1600 k > 1024k

会出现 SIGSEGV 也就可以理解了。

@WuFengXue
Copy link
Owner

在 魅蓝 Note 5 上进行验证:

当 MAX_NOGAP 为 89 的时候,可以正常运行,改到 90 后就无法运行了。

2 * 89 * 4k = 712k

因为线程栈还有其他地方会用到,所以无法达到 1016 k 的上限是可以理解的。

@beginnersun
Copy link
Author

那有没有可能在Android端调整线程栈的默认大小

@WuFengXue
Copy link
Owner

《线程堆栈大小的使用介绍》 介绍了 C 修改线程堆栈大小的方法,主要是通过 pthread_attr_setstacksize 实现的,如下:

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>//线程操作所需头文件
 
int main(void)
{
	size_t stack_size = 0; //堆栈大小变量
	pthread_attr_t attr; //线程属性结构体变量
	
	//初始化线程属性
	int ret = pthread_attr_init(&attr);
	if(ret != 0)
	{
		perror("pthread_attr_init");
		return -1;
	}
	
	stack_size = 1024*20; //堆栈大小设置为20K
    ret = pthread_attr_setstacksize(&attr, stack_size);//设置线程堆栈大小
    if(ret != 0)
	{
		perror("pthread_attr_getstacksize");
		return -1;
	}
	
	stack_size = 0;
    ret = pthread_attr_getstacksize(&attr, &stack_size);//获取线程堆栈大小
	//打印堆栈值
	printf("stack_size = %dB, %dk\n", stack_size, stack_size/1024);
 
    return 0;
}

个人对这方面的了解比较浅,不过还是不建议采用这种方式。
我这边会修改下打包好的库,将 MAX_NOGAP 调小(可能调到50左右)。

简单看了下代码,MAX_NOGAP 应该是用来控制音频分段(切片)的,语音场景语音文件应该不会特别大,这样修改应该不会导致副作用。

@beginnersun
Copy link
Author

感谢大佬的讲解,学到了很多呀!

@WuFengXue
Copy link
Owner

新版本已经发布,请用新版本试试

implementation 'com.reinhard:WeChatVoiceCodec:1.0.2'

@beginnersun
Copy link
Author

恩,可以了。给大佬点赞 ヾ(✿゚▽゚)ノ

@WuFengXue
Copy link
Owner

好的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants