[asterisk-bugs] [JIRA] (ASTERISK-29040) res_speech: Assertion on format

Reid Canavan (JIRA) noreply at issues.asterisk.org
Wed Sep 16 07:57:43 CDT 2020


     [ https://issues.asterisk.org/jira/browse/ASTERISK-29040?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Reid Canavan updated ASTERISK-29040:
------------------------------------

    Comment: was deleted

(was: We are running Asterisk 16.13 and applied this patch from Arsen ( https://groups.google.com/g/unimrcp/c/LrVK4W-b-Ho/m/zib3WYuwAQAJ?pli=1 ) which appears to have corrected the issue:
--- asterisk-13.11.2\apps\app_speech_utils.c.org	2018-03-21 19:08:57.000000000 -0700
+++ asterisk-13.11.2\apps\app_speech_utils.c	2018-03-21 19:02:25.000000000 -0700
@@ -38,12 +38,13 @@
 #include "asterisk/channel.h"
 #include "asterisk/pbx.h"
 #include "asterisk/module.h"
 #include "asterisk/lock.h"
 #include "asterisk/app.h"
 #include "asterisk/speech.h"
+#include "asterisk/format_cache.h"
 
 /*** DOCUMENTATION
 	<application name="SpeechCreate" language="en_US">
 		<synopsis>
 			Create a Speech Structure.
 		</synopsis>
@@ -543,15 +544,22 @@
 
 /*! \brief SpeechCreate() Dialplan Application */
 static int speech_create(struct ast_channel *chan, const char *data)
 {
 	struct ast_speech *speech = NULL;
 	struct ast_datastore *datastore = NULL;
+	struct ast_format_cap *cap;
 
+	if (!(cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
+		pbx_builtin_setvar_helper(chan, "ERROR", "1");
+		return 0;
+	}
+	ast_format_cap_append(cap, ast_format_slin, 0);
+
 	/* Request a speech object */
-	speech = ast_speech_new(data, ast_channel_nativeformats(chan));
+	speech = ast_speech_new(data, cap);
 	if (speech == NULL) {
 		/* Not available */
 		pbx_builtin_setvar_helper(chan, "ERROR", "1");
 		return 0;
 	}
 

)

> res_speech: Assertion on format
> -------------------------------
>
>                 Key: ASTERISK-29040
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-29040
>             Project: Asterisk
>          Issue Type: Bug
>      Security Level: None
>          Components: Resources/res_speech
>    Affects Versions: GIT
>            Reporter: Nickolay V. Shmyrev
>            Assignee: Nickolay V. Shmyrev
>              Labels: patch
>      Target Release: 13.37.0, 16.14.0, 17.8.0, 18.0.0
>
>         Attachments: app_speech_utils.diff
>
>
> This issue has been raised many times, due to memory issues user often see in the logs with res_speech
> [Feb 6 10:48:35] ERROR[17692][C-00000021] astobj2.c: FRACK!, Failed assertion bad magic number 0x0 for object 0x31990d8 (0)
> Discussion here https://community.asterisk.org/t/astobj2-c-131-internal-obj-frack-failed-assertion-bad-magic-number/73439
> The previous issue is ASTERISK-27986
> The fix is not correct, the real issue seems that the new_speech->format variable is not bumped properly. best is released with RAII, format is released in ast_speech_destroy but it is never bumped.
> In this code:
> {code}
> 	RAII_VAR(struct ast_format *, best, NULL, ao2_cleanup);
>         ......
> 	/* Can't forget the format audio is going to be in */
> 	new_speech->format = best;
> 	/* Pass ourselves to the engine so they can set us up some more and if they error out then do not create a structure */
> 	if (engine->create(new_speech, best)) {
> 		ast_mutex_destroy(&new_speech->lock);
> 		ast_free(new_speech);
> 		new_speech = NULL;
> 	}
>        return new_speech;
> }
> /*! \brief Destroy a speech structure */
> int ast_speech_destroy(struct ast_speech *speech)
> {
>          ...
> 	ao2_ref(speech->format, -1);
>         ...
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)



More information about the asterisk-bugs mailing list