[asterisk-dev] Segmentation fault (core dumped) on custom application execution

Borja SIXTO borja.sixto at ulex.fr
Fri Aug 18 03:45:05 CDT 2017


Hi,

It seems that you are not a C language developer...

static int sendfile_exec(struct ast_channel *chan, const char *data)

{

    size_t fnameLength= strlen(pbx_builtin_getvar_helper(chan, 
"MIXMONITOR_FILENAME"));

    char fileName[fnameLength];

    strcpy(fileName, pbx_builtin_getvar_helper(chan, 
"MIXMONITOR_FILENAME"));

    char fullCommand[1]= "\0";

    strcat(fullCommand, ID3V2_COMMAND);

    strcat(fullCommand, fileName);

   system(fullCommand);

    return 1;

}

replace by

static int sendfile_exec(struct ast_channel *chan, const char *data)

{

    char fileName[1024];

    strcpy(fileName, pbx_builtin_getvar_helper(chan, 
"MIXMONITOR_FILENAME"));

    char fullCommand[1024+100] = "\0";

    strcat(fullCommand, ID3V2_COMMAND);

    strcat(fullCommand, fileName);

    system(fullCommand);

    return 1;

}

To catch the coredump file and identify the C code line, use the option 
"-g" of the asterisk (you can set ulimit -c 0, if necessary)

To make this kind of process with the Asterisk it is better to use the 
Dialplan (command System()), use an AGI, or use Voximal (VoiceXML 
interpreter for Asterisk).

Regards,


Borja SIXTO from ulex.fr


Le 18/08/2017 à 09:38, Yukio Tanaka a écrit :
>
> Hello,
>
> I am in the process of writing an application for my server. 
> Compilation and installation run without a hitch. However at runtime 
> the application provokes a “Segmentation fault (core dumped)” which 
> shuts down my server. I am clueless as to what sends the error and 
> even more so on how to fix it so any help would be appreciated. Below 
> is a copy of my code.
>
> Thanks in advance for any help.
>
> Yukio
>
> /***
>
> * Send File (app_sendfile.c) by Yukio Tanaka (yukio at starcb.com)
>
> *
>
>  * Use at the end of the dialplan in a monitored call. This will:
>
> *   a) Add call metadatas to the monitor file.
>
> *   b) Send the file to the specified server using ssh.
>
> *
>
>  ******
>
> * Version 0.1 – 2017.07
>
> *
>
>  * - Testing metadata hard writing for the moment
>
> * /!\ At runtime encountering error: Segmentation fault (core dumped)
>
> ***/
>
> #include "asterisk.h"
>
> /*ASTERISK_FILE_VERSION(__FILE__, "$Revision$")*/
>
> #include "asterisk/cdr.h"
>
> #include "asterisk/logger.h"
>
> #include "asterisk/module.h"
>
> #include "asterisk/channel.h"
>
> #include "asterisk/file.h"
>
> #include "asterisk/pbx.h"
>
> /* Use id3v2 application to add an author metadata */
>
> const char ID3V2_COMMAND[]= "id3v2 -a \"Algernopp Krieger\" ";
>
> static int sendfile_exec(struct ast_channel *chan, const char *data)
>
> {
>
>    size_t fnameLength= strlen(pbx_builtin_getvar_helper(chan, 
> "MIXMONITOR_FILENAME"));
>
>    char fileName[fnameLength];
>
>    strcpy(fileName, pbx_builtin_getvar_helper(chan, 
> "MIXMONITOR_FILENAME"));
>
>    char fullCommand[1]= "\0";
>
>    strcat(fullCommand, ID3V2_COMMAND);
>
>    strcat(fullCommand, fileName);
>
>   system(fullCommand);
>
>    return 1;
>
> }
>
> static int load_module(void)
>
> {
>
> ast_register_application("SendFile", sendfile_exec, "Send a recorded 
> call to a server.", "Some description.");
>
>   return AST_MODULE_LOAD_SUCCESS;
>
> }
>
> static int unload_module(void)
>
> {
>
>   ast_cdr_unregister("SendFile");
>
>   return 0;
>
> }
>
> AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "SendFile")
>
>
>

-- 
Borja SIXTO (co-founder/manager)

Mail: borja.sixto at ulex.fr
Tel: +33(0)4 28 35 03 44  Ext. 11
Ulex Innovative Systems | 4 rue des Prairies, 38460 St Romain de Jalionas, France
www.ulex.fr

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20170818/474688eb/attachment-0001.html>


More information about the asterisk-dev mailing list