<div dir="ltr">That's weird, because I'm using exactly the same way of phone number substitution and this works to me. Ok, I'll investigate this problem as soon as possible. Thanks for report!<br></div><div class="gmail_extra">

<br><br><div class="gmail_quote">2014-07-16 14:39 GMT+04:00 Örn Arnarson <span dir="ltr"><<a href="mailto:orn@arnarson.net" target="_blank">orn@arnarson.net</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir="ltr">If you mean the python code, then here's an example:<div><div><br></div><div>divheader = "Diversion: <sip:%s@%s>;reason=unconditional\r\n" % (1234567, "10.11.12.13")<br></div>
<div>


msg.call_function("insert_hf", divheader, "Diversion")</div></div><div><br></div><div>Regards,</div><div>Örn</div><div><br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br>

<br><div class="gmail_quote">On Wed, Jul 16, 2014 at 10:32 AM, Konstantin M. <span dir="ltr"><<a href="mailto:evilzluk@gmail.com" target="_blank">evilzluk@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>Hi,<br></div>Could you please tell me the chunk of code that illustrates this problem?<br></div>



Thanks!<br><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-07-16 14:10 GMT+04:00 Örn Arnarson <span dir="ltr"><<a href="mailto:orn@arnarson.net" target="_blank">orn@arnarson.net</a>></span>:<br>





<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr">Resent after signing up, due to original message being held for review for a week:<div>

<br></div><div><span style="font-family:arial,sans-serif;font-size:12.727272033691406px">Kamailio terminates (Signal 15) after app_python crashes (signal 7) when using call_function("append_hf") with more than 1 parameter.</span><div style="font-family:arial,sans-serif;font-size:12.727272033691406px">







<br></div><div style="font-family:arial,sans-serif;font-size:12.727272033691406px"><div>Jul  9 13:53:18 vcr01 /usr/sbin/kamailio[2699]: ALERT: <core> [main.c:788]: handle_sigs(): child process 2707 exited by a signal 7</div>







<div>Jul  9 13:53:18 vcr01 /usr/sbin/kamailio[2699]: ALERT: <core> [main.c:791]: handle_sigs(): core was generated</div><div>Jul  9 13:53:18 vcr01 /usr/sbin/kamailio[2699]: INFO: <core> [main.c:803]: handle_sigs(): INFO: terminating due to SIGCHLD</div>







<div>Jul  9 13:53:18 vcr01 /usr/sbin/kamailio[2706]: INFO: <core> [main.c:854]: sig_usr(): INFO: signal 15 received</div><div><br></div><div>Actually, calling "remove_hf" with call_function seems to do exactly the same thing, though that is just with 1 param.</div>







<div><br></div><div>My problem is that I need to manipulate the Diversion headers (or rather, add a new Diversion header in the correct place (i.e. above the other Diversion header), as append_hf will always add it at the bottom.)</div>







<div><br></div><div>I've identified what part of the code makes it crash (debugging by returning early), and it seems to be the fixup part, which as far as I can tell has something to do with string formatting for kamailio:</div>







<div><div>    if (fexport->fixup != NULL) {</div><div>        if (i >= 3) {</div><div>            rval = fexport->fixup(&(act->val[3].u.data), 2);</div><div>            if (rval < 0) {</div><div>                PyErr_SetString(PyExc_RuntimeError, "Error in fixup (2)");</div>







<div>                Py_INCREF(Py_None);</div><div>                return Py_None;</div><div>            }</div><div>            act->val[3].type = MODFIXUP_ST;</div><div>        }</div><div>        if (i >= 2) {</div>







<div>            rval = fexport->fixup(&(act->val[2].u.data), 1);</div><div>            if (rval < 0) {</div><div>                PyErr_SetString(PyExc_RuntimeError, "Error in fixup (1)");</div><div>







                Py_INCREF(Py_None);</div><div>                return Py_None;</div><div>            }</div><div>            act->val[2].type = MODFIXUP_ST;</div><div>        }</div><div>        if (i == 1) {</div><div>







            rval = fexport->fixup(0, 0);</div><div>            if (rval < 0) {</div><div>                PyErr_SetString(PyExc_RuntimeError, "Error in fixup (0)");</div><div>                Py_INCREF(Py_None);</div>







<div>                return Py_None;</div><div>            }</div><div>        }</div><div>    }</div></div><div><br></div><div>I have very little experience with programming in C, and even less debugging with gdb or something similar, but from comparing this code with the way the Perl module does this, I couldn't see any obvious problems. I'm hoping someone with familiarity with the kamailio functions, such as fixup, might be able to identify the problem.</div>







<div><br></div><div>Judging from the exit code of app_python, my (uninformed) guess would be that there's an attempt to access or manipulate something in an out-of-scope memory address.</div></div><div style="font-family:arial,sans-serif;font-size:12.727272033691406px">







<br></div><div style="font-family:arial,sans-serif;font-size:12.727272033691406px">Any suggestions would be greatly appreciated. I've written a quite large routing function in python and I'd like to avoid rewriting it in a different scripting language if possible.</div>







<div style="font-family:arial,sans-serif;font-size:12.727272033691406px"><br></div><div style="font-family:arial,sans-serif;font-size:12.727272033691406px">The kamailio version I'm running is 4.0.4</div><div style="font-family:arial,sans-serif;font-size:12.727272033691406px">







<br></div><div style="font-family:arial,sans-serif;font-size:12.727272033691406px">Regards,</div><div style="font-family:arial,sans-serif;font-size:12.727272033691406px">Örn</div></div></div>
<br></div></div>_______________________________________________<br>
sr-dev mailing list<br>
<a href="mailto:sr-dev@lists.sip-router.org" target="_blank">sr-dev@lists.sip-router.org</a><br>
<a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev</a><br>
<br></blockquote></div><br></div>
<br>_______________________________________________<br>
sr-dev mailing list<br>
<a href="mailto:sr-dev@lists.sip-router.org" target="_blank">sr-dev@lists.sip-router.org</a><br>
<a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev</a><br>
<br></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
sr-dev mailing list<br>
<a href="mailto:sr-dev@lists.sip-router.org">sr-dev@lists.sip-router.org</a><br>
<a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev</a><br>
<br></blockquote></div><br></div>