Random segmentation fault
serxoz opened this issue · 6 comments
Hi.
I'm here begging for help or at least some directions.
I get sometimes, not always, this segfault:
#0 __memmove_sse2_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:489
#1 0x00007f3d8dc41fdd in vosk_recog_write (speech=0x7f3d8800f6b0, data=<optimized out>, len=320)
at res_speech_vosk.c:156
#2 0x00007f3d8d98055a in speech_background (chan=0x7f3d800056e0, data=<optimized out>) at app_speech_utils.c:855
Don't always get it, it's so random!
And to put things more easy, I've modified app_speech_utils.c a little. But, I think my modifications don't have to do with this part of code... I'm not 100% sure.
I attach here my asterisk patch and my vosk-asterisk patch for the braves who want to try. I have tried them with 16.18.0 and git version of asterisk. My modifications try to solve a pair of problems I encounter:
- SpeechBackground() stops the locution when detect speech and I want that don't stop and keep all text of the speech during the play of the locution.
- SpeechBackground() timeout fails in the way that if user start to speak while in the locution play and don't shut up, timeout triggers and don't get any speech.
Hope you can at least point me in a good direction to follow.
Thank you in advance.
Hi again.
I can see in gdb this:
#1 0x00007f3d8dc41fdd in vosk_recog_write (speech=0x7f3d8800f6b0, data=<optimized out>, len=320)
at res_speech_vosk.c:156
156 memcpy(vosk_speech->buf + vosk_speech->offset, data, len);
(gdb) print vosk_speech->offset
$1 = 11010520
Maybe offset is the cause?
You'd better use strncat in your patch instead of strcat, otherwise you might get buffer overflow.
You also better accumulate text in asterisk variables instead of patching the sources.
The text is acumulated while the locution in SpeechBackgrond() is playing, I think can't do that in dialplan... :S
I think the problem is in the assert. Look here:
#19
Although despite correcting the name of the variable, it still allows a large offset to pass. I had another core dump with an offset value of 524616.
I think the problem is in the assert. Look here:
asserts are disabled by default, still, it is a valid fix I think, thank you.
Although despite correcting the name of the variable, it still allows a large offset to pass. I had another core dump with an offset value of 524616.
You can probably add a printf of the offset value every frame and collect logs showing the offset changes.
You still need to fix strcat issue in your code.