[sr-dev] benchmark rpc commands causing kamailio to crash

Daniel-Constantin Mierla miconda at gmail.com
Thu Jun 1 10:04:29 CEST 2017


Hello,

can you make a pull request with your fixes on github project? It makes
it easier to review and merge if all ok.

Cheers,
Daniel

On 31.05.17 18:06, David Escartín Almudévar wrote:
> hello all
>
> today testing kamailio 5.0.1 version we have seen that some rpc
> commands of benchmark module are not working fine.
>
> when trying to change enable_global parameter, setting 1 for example
> it says that the parameter is invalid
> /usr/local/kamailio-5.0/sbin/kamcmd -s udp:127.0.0.1:2046
> benchmark.enable_global 1
> error: 500 - Invalid Parameter Value
>
> besides, it also permits to set a granularity value of 0 without
> giving error.
> By doing that, if the kamailio has calls in progress, the kamailio get
> a crash
>
> Core was generated by `/usr/local/kamailio-5.0/sbin/kamailio -P
> /var/run/kamailio/kamailio_talos.pid -'.
> Program terminated with signal 8, Arithmetic exception.
> #0  0x00007f4d55989757 in _bm_log_timer (id=0) at benchmark.c:320
> 320 if ((bm_mycfg->tindex[id]->calls % bm_mycfg->granularity) == 0)
> Missing separate debuginfos, use: debuginfo-install
> glibc-2.12-1.132.el6.x86_64 libxml2-2.7.6-14.el6.x86_64
> pcre-7.8-6.el6.x86_64 zlib-1.2.3-29.el6.x86_64
>
> i understand that maybe is trying to divide by 0 to calcutate the
> benchmark stats.
>
> checking the functions, we made a change to fix this problem, by
> chaning the type of the vars defined as "int", instead of "long int".
> this way seems the commands work fine
>
> /usr/local/kamailio-5.0/sbin/kamcmd -s udp:127.0.0.1:2046
> benchmark.enable_global 1
> /usr/local/kamailio-5.0/sbin/kamcmd -s udp:127.0.0.1:2046
> benchmark.granularity 0
> error: 500 - Invalid Parameter Value
>
> this are the changes we made
> index d40469b..5a353d5 100644
> --- a/src/modules/benchmark/benchmark.c
> +++ b/src/modules/benchmark/benchmark.c
> @@ -479,7 +479,8 @@ static inline int fixup_bm_timer(void** param, int
> param_no)
>   */
> void bm_rpc_enable_global(rpc_t* rpc, void* ctx)
> {
> -       long int v1;
> +       int v1;
> +       /*long int v1;*/
>         if(rpc->scan(ctx, "d", (int*)(&v1))<1) {
>                 LM_WARN("no parameters\n");
>                 rpc->fault(ctx, 500, "Invalid Parameters");
> @@ -518,7 +519,8 @@ void bm_rpc_enable_timer(rpc_t* rpc, void* ctx)
>
> void bm_rpc_granularity(rpc_t* rpc, void* ctx)
> {
> -       long int v1;
> +       int v1;
> +        /*long int v1;*/
>         if(rpc->scan(ctx, "d", (int*)(&v1))<1) {
>                 LM_WARN("no parameters\n");
>                 rpc->fault(ctx, 500, "Invalid Parameters");
> @@ -533,7 +535,8 @@ void bm_rpc_granularity(rpc_t* rpc, void* ctx)
>
> void bm_rpc_loglevel(rpc_t* rpc, void* ctx)
> {
> -       long int v1;
> +       int v1;
> +       /*long int v1;*/
>         if(rpc->scan(ctx, "d", (int*)(&v1))<1) {
>                 LM_WARN("no parameters\n");
>                 rpc->fault(ctx, 500, "Invalid Parameters");
>
> could you please check if this fix is enough? and maybe there can be
> some other functions with this problem?
>
> thanks  alot and regards
> david
>
>
> _______________________________________________
> Kamailio (SER) - Development Mailing List
> sr-dev at lists.kamailio.org
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev



-- 
Daniel-Constantin Mierla
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio Advanced Training - www.asipto.com
Kamailio World Conference - www.kamailioworld.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-dev/attachments/20170601/a9339273/attachment-0001.html>


More information about the sr-dev mailing list