Kitt-AI / snowboy

Future versions with model training module will be maintained through a forked version here: https://github.com/seasalt-ai/snowboy
Other
3.11k stars 1.01k forks source link

Native crash on snowboyJNI_delete ( Android ) #168

Open KushtrimPacaj opened 7 years ago

KushtrimPacaj commented 7 years ago

I integrated this library in my application, because I wanted to add the "Alexa" keyword functionality to my existing Alexa AVS implementation. It working fine most of the time, but my app sometimes seemingly randomly crashes, with a native error on this library :

04-11 10:54:38.275 159-159/? I/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
04-11 10:54:38.275 159-159/? I/DEBUG: Build fingerprint: 'Android/rk3288_box/rk3288_box:5.1.1/LMY49F/kushtrim04071948:userdebug/test-keys'
04-11 10:54:38.275 159-159/? I/DEBUG: Revision: '0'
04-11 10:54:38.275 159-159/? I/DEBUG: ABI: 'arm'
04-11 10:54:38.275 159-159/? I/DEBUG: pid: 5628, tid: 5640, name: FinalizerDaemon  >>> com.kushtrim.myapp <<<
04-11 10:54:38.275 159-159/? I/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0xdeadbaad
04-11 10:54:38.305 159-159/? I/DEBUG: Abort message: 'invalid address or address of corrupt block 0x6bc06b4 passed to dlfree'
04-11 10:54:38.305 159-159/? I/DEBUG:     r0 00000000  r1 a3b0b5f8  r2 deadbaad  r3 00000000
04-11 10:54:38.305 159-159/? I/DEBUG:     r4 06bc06b4  r5 b6e270e8  r6 93493000  r7 06bc06bc
04-11 10:54:38.305 159-159/? I/DEBUG:     r8 b6e25dd4  r9 b801a160  sl 1348a940  fp 139b2660
04-11 10:54:38.305 159-159/? I/DEBUG:     ip b6e2164c  sp a3b0b9e8  lr b6df5f53  pc b6df5f54  cpsr 60070030
04-11 10:54:38.305 159-159/? I/DEBUG: backtrace:
04-11 10:54:38.305 159-159/? I/DEBUG:     #00 pc 0002bf54  /system/lib/libc.so (dlfree+1239)
04-11 10:54:38.305 159-159/? I/DEBUG:     #01 pc 00012257  /system/lib/libc.so (free+10)
04-11 10:54:38.306 159-159/? I/DEBUG:     #02 pc 0006a4cb  /data/app/com.kushtrim.myapp-1/lib/arm/libsnowboy-detect-android.so (TwAec_FreeAec+16)
04-11 10:54:38.306 159-159/? I/DEBUG:     #03 pc 0006840f  /data/app/com.kushtrim.myapp-1/lib/arm/libsnowboy-detect-android.so (TwAec_Free+10)
04-11 10:54:38.306 159-159/? I/DEBUG:     #04 pc 000666a5  /data/app/com.kushtrim.myapp-1/lib/arm/libsnowboy-detect-android.so (AEC_Exit+8)
04-11 10:54:38.306 159-159/? I/DEBUG:     #05 pc 0005bc07  /data/app/com.kushtrim.myapp-1/lib/arm/libsnowboy-detect-android.so (TVqe_Java_Free+22)
04-11 10:54:38.306 159-159/? I/DEBUG:     #06 pc 000467f4  /data/app/com.kushtrim.myapp-1/lib/arm/libsnowboy-detect-android.so (snowboy::VqeStream::~VqeStream()+24)
04-11 10:54:38.306 159-159/? I/DEBUG:     #07 pc 00046850  /data/app/com.kushtrim.myapp-1/lib/arm/libsnowboy-detect-android.so (snowboy::VqeStream::~VqeStream()+8)
04-11 10:54:38.306 159-159/? I/DEBUG:     #08 pc 0002ea18  /data/app/com.kushtrim.myapp-1/lib/arm/libsnowboy-detect-android.so (snowboy::PipelineDetect::~PipelineDetect()+156)
04-11 10:54:38.306 159-159/? I/DEBUG:     #09 pc 0002fb2c  /data/app/com.kushtrim.myapp-1/lib/arm/libsnowboy-detect-android.so (snowboy::PipelineDetect::~PipelineDetect()+8)
04-11 10:54:38.306 159-159/? I/DEBUG:     #10 pc 0001c144  /data/app/com.kushtrim.myapp-1/lib/arm/libsnowboy-detect-android.so (snowboy::SnowboyDetect::~SnowboyDetect()+60)
04-11 10:54:38.306 159-159/? I/DEBUG:     #11 pc 0001b520  /data/app/com.kushtrim.myapp-1/lib/arm/libsnowboy-detect-android.so (Java_ai_kitt_snowboy_snowboyJNI_delete_1SnowboyDetect+24)

I've been trying all day, but can't pinpoint why it is happening, or how to fix it. Is there something that I could be doing different that might cause this ? How do I debug the issue ?

KushtrimPacaj commented 7 years ago

For anyone who encounters this issue in the future, here is what I was doing different, and what caused to crash:

I was initializing the RecordingThread in onResume, and stopping/nullifying it on onPause. After going through this process a few times, this error would show up. Im guessing it has something to do with the finalizer of SnowBoy detect. Removing the init/nullify from the lifecycle methods, and just calling startRecording/stopRecording, solved the issue.

Even though I managed to workaround, I'd be really interested to know why it was crashing.

chenguoguo commented 7 years ago

Thanks for the workaround. We'll take a look

efeyc commented 7 years ago

Do you have any plan to fix this issue in the near future?

praharshbhatt commented 6 years ago

This did not solve the issue. :( Logs-

00 pc 000000000004abf4 /system/lib/libc.so (tgkill+12)

01 pc 0000000000048393 /system/lib/libc.so (pthread_kill+34)

02 pc 000000000001d485 /system/lib/libc.so (raise+10)

03 pc 0000000000018fc1 /system/lib/libc.so (__libc_android_abort+34)

04 pc 0000000000017024 /system/lib/libc.so (abort+4)

05 pc 000000000001b47f /system/lib/libc.so (__libc_fatal+22)

06 pc 0000000000065c6b /system/lib/libc.so (ifree+962)

07 pc 0000000000065d2f /system/lib/libc.so (je_free+70)

08 pc 0000000000075bf7 /data/app/com.multiverse.jarvis-1/lib/arm/libsnowboy-detect-android.so (TwAec_FreeAec+222)

09 pc 000000000006831f /data/app/com.multiverse.jarvis-1/lib/arm/libsnowboy-detect-android.so (TwAec_Free+10)

10 pc 00000000000665b1 /data/app/com.multiverse.jarvis-1/lib/arm/libsnowboy-detect-android.so (AEC_Exit+8)

11 pc 000000000006622f /data/app/com.multiverse.jarvis-1/lib/arm/libsnowboy-detect-android.so (TVqe_Java_Free+22)

12 pc 000000000004e310 /data/app/com.multiverse.jarvis-1/lib/arm/libsnowboy-detect-android.so (_ZN7snowboy9VqeStreamD2Ev+24)

13 pc 000000000004e36c /data/app/com.multiverse.jarvis-1/lib/arm/libsnowboy-detect-android.so (_ZN7snowboy9VqeStreamD0Ev+8)

14 pc 0000000000032814 /data/app/com.multiverse.jarvis-1/lib/arm/libsnowboy-detect-android.so (_ZN7snowboy14PipelineDetectD2Ev+156)

15 pc 0000000000033730 /data/app/com.multiverse.jarvis-1/lib/arm/libsnowboy-detect-android.so (_ZN7snowboy14PipelineDetectD0Ev+8)

16 pc 000000000001dff8 /data/app/com.multiverse.jarvis-1/lib/arm/libsnowboy-detect-android.so (_ZN7snowboy13SnowboyDetectD1Ev+60)

17 pc 000000000001d1b8 /data/app/com.multiverse.jarvis-1/lib/arm/libsnowboy-detect-android.so (Java_ai_kitt_snowboy_snowboyJNI_delete_1SnowboyDetect+24)