FreeSWITCH

API::execute memory leak

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: freeswitch-core
  • Platform:
    Linux x86/gcc
  • Uname:
    2.6.18-128.1.14.el5 #1 SMP Wed Jun 17 06:40:54 EDT 2009 i686 i686 i386 GNU/Linux
  • CPU Info:
    Hide
    processor : 0
    vendor_id : GenuineIntel
    cpu family : 6
    model : 23
    model name : Intel(R) Xeon(R) CPU L5408 @ 2.13GHz
    stepping : 10
    cpu MHz : 2128.039
    cache size : 6144 KB
    physical id : 0
    siblings : 4
    core id : 0
    cpu cores : 4
    apicid : 0
    fdiv_bug : no
    hlt_bug : no
    f00f_bug : no
    coma_bug : no
    fpu : yes
    fpu_exception : yes
    cpuid level : 13
    wp : yes
    flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc pni monitor ds_cpl vmx est tm2 cx16 xtpr lahf_lm
    bogomips : 4428.47

    processor : 1
    vendor_id : GenuineIntel
    cpu family : 6
    model : 23
    model name : Intel(R) Xeon(R) CPU L5408 @ 2.13GHz
    stepping : 10
    cpu MHz : 2128.039
    cache size : 6144 KB
    physical id : 0
    siblings : 4
    core id : 1
    cpu cores : 4
    apicid : 1
    fdiv_bug : no
    hlt_bug : no
    f00f_bug : no
    coma_bug : no
    fpu : yes
    fpu_exception : yes
    cpuid level : 13
    wp : yes
    flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc pni monitor ds_cpl vmx est tm2 cx16 xtpr lahf_lm
    bogomips : 4255.81

    processor : 2
    vendor_id : GenuineIntel
    cpu family : 6
    model : 23
    model name : Intel(R) Xeon(R) CPU L5408 @ 2.13GHz
    stepping : 10
    cpu MHz : 2128.039
    cache size : 6144 KB
    physical id : 0
    siblings : 4
    core id : 2
    cpu cores : 4
    apicid : 2
    fdiv_bug : no
    hlt_bug : no
    f00f_bug : no
    coma_bug : no
    fpu : yes
    fpu_exception : yes
    cpuid level : 13
    wp : yes
    flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc pni monitor ds_cpl vmx est tm2 cx16 xtpr lahf_lm
    bogomips : 4255.82

    processor : 3
    vendor_id : GenuineIntel
    cpu family : 6
    model : 23
    model name : Intel(R) Xeon(R) CPU L5408 @ 2.13GHz
    stepping : 10
    cpu MHz : 2128.039
    cache size : 6144 KB
    physical id : 0
    siblings : 4
    core id : 3
    cpu cores : 4
    apicid : 3
    fdiv_bug : no
    hlt_bug : no
    f00f_bug : no
    coma_bug : no
    fpu : yes
    fpu_exception : yes
    cpuid level : 13
    wp : yes
    flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc pni monitor ds_cpl vmx est tm2 cx16 xtpr lahf_lm
    bogomips : 4221.20
    Show
    processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 23 model name : Intel(R) Xeon(R) CPU L5408 @ 2.13GHz stepping : 10 cpu MHz : 2128.039 cache size : 6144 KB physical id : 0 siblings : 4 core id : 0 cpu cores : 4 apicid : 0 fdiv_bug : no hlt_bug : no f00f_bug : no coma_bug : no fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc pni monitor ds_cpl vmx est tm2 cx16 xtpr lahf_lm bogomips : 4428.47 processor : 1 vendor_id : GenuineIntel cpu family : 6 model : 23 model name : Intel(R) Xeon(R) CPU L5408 @ 2.13GHz stepping : 10 cpu MHz : 2128.039 cache size : 6144 KB physical id : 0 siblings : 4 core id : 1 cpu cores : 4 apicid : 1 fdiv_bug : no hlt_bug : no f00f_bug : no coma_bug : no fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc pni monitor ds_cpl vmx est tm2 cx16 xtpr lahf_lm bogomips : 4255.81 processor : 2 vendor_id : GenuineIntel cpu family : 6 model : 23 model name : Intel(R) Xeon(R) CPU L5408 @ 2.13GHz stepping : 10 cpu MHz : 2128.039 cache size : 6144 KB physical id : 0 siblings : 4 core id : 2 cpu cores : 4 apicid : 2 fdiv_bug : no hlt_bug : no f00f_bug : no coma_bug : no fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc pni monitor ds_cpl vmx est tm2 cx16 xtpr lahf_lm bogomips : 4255.82 processor : 3 vendor_id : GenuineIntel cpu family : 6 model : 23 model name : Intel(R) Xeon(R) CPU L5408 @ 2.13GHz stepping : 10 cpu MHz : 2128.039 cache size : 6144 KB physical id : 0 siblings : 4 core id : 3 cpu cores : 4 apicid : 3 fdiv_bug : no hlt_bug : no f00f_bug : no coma_bug : no fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc pni monitor ds_cpl vmx est tm2 cx16 xtpr lahf_lm bogomips : 4221.20
  • GCC Version:
    gcc version 4.1.2 20080704 (Red Hat 4.1.2-44)
  • FreeSWITCH GIT Revision:
    freeswitch-1.0.4pre9
  • Reproduced with GIT HEAD?:
    14022
  • Description:
    Hide
    I have a simple script who does monitor the FS db.
    here the miniature test script i used to test.
    local api = freeswitch.API()
    local endlessloop = "true"
    local count = 0
    repeat
            count = count + 1
            r = api:execute("regex", "testing1234|/(\\d+)/|$1");
            if count == 10000 then endlessloop = "false"
            end
    until endlessloop == "false"

    this does produce:

    ==28840== 10,222,592 bytes in 9,983 blocks are definitely lost in loss record 48 of 48
    ==28840== at 0x40053C0: malloc (vg_replace_malloc.c:149)
    ==28840== by 0x40ABEFD: API::execute(char const*, char const*) (switch_cpp.cpp:181)
    ==28840== by 0x125F4BFF: ??? (mod_lua_wrap.cpp:1820)
    ==28840== by 0x125FBAB2: luaD_precall (ldo.c:319)
    ==28840== by 0x12604E7F: luaV_execute (lvm.c:587)
    ==28840== by 0x125FBF2F: luaD_call (ldo.c:377)
    ==28840== by 0x125F90E0: ??? (lapi.c:800)
    ==28840== by 0x125FB5F2: luaD_rawrunprotected (ldo.c:116)
    ==28840== by 0x125FB657: luaD_pcall (ldo.c:463)
    ==28840== by 0x125F8F33: lua_pcall (lapi.c:821)
    ==28840== by 0x125DE171: ??? (mod_lua.cpp:91)
    ==28840== by 0x125DE70C: ??? (mod_lua.cpp:174)
    ==28840== LEAK SUMMARY:
    ==28840== definitely lost: 10,233,960 bytes in 9,991 blocks.
    ==28840== indirectly lost: 3,934 bytes in 24 blocks.
    ==28840== possibly lost: 16,544 bytes in 17 blocks.
    ==28840== still reachable: 351,443 bytes in 2,721 blocks.
    ==28840== suppressed: 0 bytes in 0 blocks.
    ==28840== Reachable blocks (those to which a pointer was found) are not shown.


    it does not matter what is executed in the api:execute function. I used it to endless loop every 20sec after a day it's up to 400M ram usage.

    Show
    I have a simple script who does monitor the FS db. here the miniature test script i used to test. local api = freeswitch.API() local endlessloop = "true" local count = 0 repeat         count = count + 1         r = api:execute("regex", "testing1234|/(\\d+)/|$1");         if count == 10000 then endlessloop = "false"         end until endlessloop == "false" this does produce: ==28840== 10,222,592 bytes in 9,983 blocks are definitely lost in loss record 48 of 48 ==28840== at 0x40053C0: malloc (vg_replace_malloc.c:149) ==28840== by 0x40ABEFD: API::execute(char const*, char const*) (switch_cpp.cpp:181) ==28840== by 0x125F4BFF: ??? (mod_lua_wrap.cpp:1820) ==28840== by 0x125FBAB2: luaD_precall (ldo.c:319) ==28840== by 0x12604E7F: luaV_execute (lvm.c:587) ==28840== by 0x125FBF2F: luaD_call (ldo.c:377) ==28840== by 0x125F90E0: ??? (lapi.c:800) ==28840== by 0x125FB5F2: luaD_rawrunprotected (ldo.c:116) ==28840== by 0x125FB657: luaD_pcall (ldo.c:463) ==28840== by 0x125F8F33: lua_pcall (lapi.c:821) ==28840== by 0x125DE171: ??? (mod_lua.cpp:91) ==28840== by 0x125DE70C: ??? (mod_lua.cpp:174) ==28840== LEAK SUMMARY: ==28840== definitely lost: 10,233,960 bytes in 9,991 blocks. ==28840== indirectly lost: 3,934 bytes in 24 blocks. ==28840== possibly lost: 16,544 bytes in 17 blocks. ==28840== still reachable: 351,443 bytes in 2,721 blocks. ==28840== suppressed: 0 bytes in 0 blocks. ==28840== Reachable blocks (those to which a pointer was found) are not shown. it does not matter what is executed in the api:execute function. I used it to endless loop every 20sec after a day it's up to 400M ram usage.
  • Environment:
    CentOS 5.3
    2.6.18-128.1.14.el5 #1 SMP Wed Jun 17 06:40:54 EDT 2009 i686 i686 i386 GNU/Linux
    FS 1.0.4Pre9

Activity

Hide
Andre Schwaller added a comment - 30/Jun/09 5:02 PM
now i had a closer look at switch_cpp.cpp 181
a few lines below i spotted a API::executeString(const char *cmd)
so i try to use API::executeString with lua... and no memory problem jumping at me right away.
So i dared to modify the :

SWITCH_DECLARE(const char *) API::execute(const char *cmd, const char *arg)
{
        switch_stream_handle_t stream = { 0 };

        switch_assert(cmd);
        this_check("");
        switch_safe_free(last_data);
        SWITCH_STANDARD_STREAM(stream);
        switch_api_execute(cmd, arg, NULL, &stream);
        last_data = (char *) stream.data;
        return last_data;
}

so it does basically the same as API::executeString. I would say that inserting the missing "switch_safe_free(last_data);" did solve the problem.
I keep that now for my production env. until some one who knows better than me solves the issue.
Show
Andre Schwaller added a comment - 30/Jun/09 5:02 PM now i had a closer look at switch_cpp.cpp 181 a few lines below i spotted a API::executeString(const char *cmd) so i try to use API::executeString with lua... and no memory problem jumping at me right away. So i dared to modify the : SWITCH_DECLARE(const char *) API::execute(const char *cmd, const char *arg) {         switch_stream_handle_t stream = { 0 };         switch_assert(cmd);         this_check("");         switch_safe_free(last_data);         SWITCH_STANDARD_STREAM(stream);         switch_api_execute(cmd, arg, NULL, &stream);         last_data = (char *) stream.data;         return last_data; } so it does basically the same as API::executeString. I would say that inserting the missing "switch_safe_free(last_data);" did solve the problem. I keep that now for my production env. until some one who knows better than me solves the issue.
Hide
Brian West added a comment - 01/Jul/09 5:59 PM
Committed revision 14097.
Show
Brian West added a comment - 01/Jul/09 5:59 PM Committed revision 14097.
Hide
Anthony Minessale II added a comment - 01/Jul/09 5:59 PM
your suggestion was correct.
fixed in rev 14097
Show
Anthony Minessale II added a comment - 01/Jul/09 5:59 PM your suggestion was correct. fixed in rev 14097

People

Dates

  • Created:
    30/Jun/09 4:49 AM
    Updated:
    27/Sep/10 1:45 AM
    Resolved:
    01/Jul/09 5:59 PM