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

Random segmentation fault #18

Closed
serxoz opened this issue Sep 1, 2021 · 6 comments
Closed

Random segmentation fault #18

serxoz opened this issue Sep 1, 2021 · 6 comments

Comments

@serxoz
Copy link
Contributor

serxoz commented Sep 1, 2021

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.

ast-patch.txt
vosk-ast-patch.txt
core-thread1.txt

@serxoz
Copy link
Contributor Author

serxoz commented Sep 2, 2021

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?

@nshmyrev
Copy link
Contributor

nshmyrev commented Sep 2, 2021

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.

@serxoz
Copy link
Contributor Author

serxoz commented Sep 2, 2021

The text is acumulated while the locution in SpeechBackgrond() is playing, I think can't do that in dialplan... :S

@serxoz
Copy link
Contributor Author

serxoz commented Sep 2, 2021

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.

@nshmyrev
Copy link
Contributor

nshmyrev commented Sep 2, 2021

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.

@serxoz
Copy link
Contributor Author

serxoz commented Sep 3, 2021

I was thinking assert was enabled... :(
I could solve the problem with this: #20
I've tested it with more than 200 calls and is working OK.

Thank you for your recommendation on strncat().

@serxoz serxoz closed this as completed Sep 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants