Sponsor: VoiceMeUp - Corporate & Wholesale VoIP Services

VoIP Mailing List Archives
Mailing list archives for the VoIP community
 SearchSearch 

[Freeswitch-users] Switch_curl


 
Post new topic   Reply to topic    VoIP Mailing List Archives Forum Index -> freeSWITCH Users
View previous topic :: View next topic  
Author Message
anthony.minessale at g...
Guest





PostPosted: Tue Mar 15, 2016 5:43 pm    Post subject: [Freeswitch-users] Switch_curl Reply with quote

Curl is used in a few places and is not unstable.  Study some of those mods and maybe you can see how to use it in a typical situation.  Probably its related to memory management or lifecycle of objects you may be using.

On Tuesday, March 15, 2016, Chris Mandra <mandra@gmail.com (mandra@gmail.com)> wrote:
Quote:
Hey guys, I'm working on a simple media bug module using FS 1.6. When a call comes in I'm calling switch_curl doing an http get. 

In switch_standard_app I use switch_curl and invoke switch_curl_easy_perform and exit after that.
Calling switch_curl seems very unstable. It's crashing free switch most of the time.  Are there any things I should be looking for related to this? I'm wondering if maybe this is a threading issue? Any ideas?
I've included some backtraces


Thanks, chris






(gdb) bt
#0  0x00007f8f00c59cc9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00007f8f00c5d0d8 in __GI_abort () at abort.c:89
#2  0x00007f8f00c96394 in __libc_message (do_abort=do_abort@entry=1, fmt=fmt@entry=0x7f8f00da4b28 "*** Error in `%s': %s: 0x%s ***\n") at ../sysdeps/posix/libc_fatal.c:175
#3  0x00007f8f00ca266e in malloc_printerr (ptr=<optimized out>, str=0x7f8f00da0c19 "free(): invalid pointer", action=1) at malloc.c:4996
#4  _int_free (av=<optimized out>, p=<optimized out>, have_lock=0) at malloc.c:3840
#5  0x00007f8f01334567 in switch_log_node_free (pnode=pnode@entry=0x7f8eb2b1f158) at src/switch_log.c:136
#6  0x00007f8eeb192a24 in read_packet (listener=listener@entry=0x7f8ebc027898, event=event@entry=0x7f8eb2b1f7f0, timeout=timeout@entry=0) at mod_event_socket.c:1361
#7  0x00007f8eeb1988a0 in listener_run (thread=<optimized out>, obj=0x7f8ebc027898) at mod_event_socket.c:2719
#8  0x00007f8f01544430 in dummy_worker (opaque=0x7f8eb2be4868) at threadproc/unix/thread.c:151
#9  0x00007f8f00ff0182 in start_thread (arg=0x7f8eb2b20700) at pthread_create.c:312
#10 0x00007f8f00d1d47d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111


[
5:44
]
(gdb) bt full
#0  0x00007f8f00c59cc9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
       resultvar = 0
       pid = 18329
       selftid = 18421
#1  0x00007f8f00c5d0d8 in __GI_abort () at abort.c:89
       save_stage = 2
       act = {__sigaction_handler = {sa_handler = 0x0, sa_sigaction = 0x0}, sa_mask = {__val = {0 <repeats 16 times>}}, sa_flags = 0, sa_restorer = 0x0}
       sigs = {__val = {32, 0 <repeats 15 times>}}
#2  0x00007f8f00c96394 in __libc_message (do_abort=do_abort@entry=1, fmt=fmt@entry=0x7f8f00da4b28 "*** Error in `%s': %s: 0x%s ***\n") at ../sysdeps/posix/libc_fatal.c:175
       ap = {{gp_offset = 40, fp_offset = 32654, overflow_arg_area = 0x7f8eb2b1f010, reg_save_area = 0x7f8eb2b1efa0}}
       fd = 2
       on_2 = <optimized out>
       list = <optimized out>
       nlist = <optimized out>
       cp = <optimized out>
       written = <optimized out>
#3  0x00007f8f00ca266e in malloc_printerr (ptr=<optimized out>, str=0x7f8f00da0c19 "free(): invalid pointer", action=1) at malloc.c:4996
       buf = "00007f8ed0036700"
       cp = <optimized out>
#4  _int_free (av=<optimized out>, p=<optimized out>, have_lock=0) at malloc.c:3840
       size = <optimized out>
       fb = <optimized out>
       nextchunk = <optimized out>
       nextsize = <optimized out>
       nextinuse = <optimized out>
       prevsize = <optimized out>
       bck = <optimized out>
       fwd = <optimized out>
       errstr = <optimized out>
       locked = <optimized out>
#5  0x00007f8f01334567 in switch_log_node_free (pnode=pnode@entry=0x7f8eb2b1f158) at src/switch_log.c:136
       node = 0x7f8ed8012ab0
#6  0x00007f8eeb192a24 in read_packet (listener=listener@entry=0x7f8ebc027898, event=event@entry=0x7f8eb2b1f7f0, timeout=timeout@entry=0) at mod_event_socket.c:1361
       dnode = 0x7f8ed8012ab0
       do_sleep = <optimized out>
       mlen = 0
       bytes = 0
       mbuf = 0x7f8ecc1ebfc0 ""
       buf = "Content-Type: log/data\nContent-Length: 88\nLog-Level: 7\nText-Channel: 3\nLog-File: param_hps_strategy.cpp\nLog-Func: retrieve\nLog-Line: 115\nUser-Data: \347@\247\a\n\n\000\n\n\000\065-418f-a6d1-9dc8f48e0cf9\n\n\000\000\071\n\n\000c8f48e0cf9"...
       len = 88
       status = SWITCH_STATUS_BREAK
       count = 0
       elapsed = <optimized out>
       start = 1457966137
       pop = 0x7f8ed8012ab0
       ptr = 0x7f8ecc1ebfc0 ""
       crcount = 0 '\000'
       buf_len = 2048
       channel = 0x0
       clen = 0
       __PRETTY_FUNCTION__ = "read_packet"
       __func__ = "read_packet"
#7  0x00007f8eeb1988a0 in listener_run (thread=<optimized out>, obj=0x7f8ebc027898) at mod_event_socket.c:2719
       listener = 0x7f8ebc027898
       buf = '\000' <repeats 1023 times>
       len = 1024
       status = <optimized out>
       event = 0x0
       reply = "\000OK log level  [7]", '\000' <repeats 493 times>
       session = 0x0
       channel = 0x0
       revent = 0x0
       var = <optimized out>
       locked = 1
       __PRETTY_FUNCTION__ = "listener_run"
       __func__ = "listener_run"
#8  0x00007f8f01544430 in dummy_worker (opaque=0x7f8eb2be4868) at threadproc/unix/thread.c:151
       thread = 0x7f8eb2be4868
#9  0x00007f8f00ff0182 in start_thread (arg=0x7f8eb2b20700) at pthread_create.c:312
       __res = <optimized out>
       pd = 0x7f8eb2b20700
       now = <optimized out>
       unwind_buf = {cancel_jmp_buf = {{jmp_buf = {140250860095232, -640791540281233069, 0, 0, 140250860095936, 140250860095232, 578173923610734931, 577994035108262227}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
       not_first_call = <optimized out>
       pagesize_m1 = <optimized out>
       sp = <optimized out>
       freesize = <optimized out>
       __PRETTY_FUNCTION__ = "start_thread"
#10 0x00007f8f00d1d47d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
No locals




--
Anthony Minessale II       ♬ @anthmfs  ♬ @FreeSWITCH  ♬
http://freeswitch.org/  ☞ http://cluecon.com/  ☞ http://twitter.com/FreeSWITCH
irc.freenode.net #freeswitch ☞ http://freeswitch.org/g+


ClueCon Weekly Development Call 

☎ sip:888@conference.freeswitch.org ([email]sip%3A888@conference.freeswitch.org[/email])  ☎ +19193869900 




https://www.youtube.com/watch?v=9XXgW34t40s
https://www.youtube.com/watch?v=NLaDpGQuZDA
Back to top
mandra at gmail.com
Guest





PostPosted: Tue Mar 15, 2016 7:49 pm    Post subject: [Freeswitch-users] Switch_curl Reply with quote

Should curl calls be done in separate thread or is it ok to do them in the main thread of modules?
On Tuesday, March 15, 2016, Anthony Minessale <anthony.minessale@gmail.com (anthony.minessale@gmail.com)> wrote:
Quote:
Curl is used in a few places and is not unstable.  Study some of those mods and maybe you can see how to use it in a typical situation.  Probably its related to memory management or lifecycle of objects you may be using.

On Tuesday, March 15, 2016, Chris Mandra <[url=javascript:_e(%7B%7D,'cvml','mandra@gmail.com');]mandra@gmail.com[/url]> wrote:
Quote:
Hey guys, I'm working on a simple media bug module using FS 1.6. When a call comes in I'm calling switch_curl doing an http get. 

In switch_standard_app I use switch_curl and invoke switch_curl_easy_perform and exit after that.
Calling switch_curl seems very unstable. It's crashing free switch most of the time.  Are there any things I should be looking for related to this? I'm wondering if maybe this is a threading issue? Any ideas?
I've included some backtraces


Thanks, chris






(gdb) bt
#0  0x00007f8f00c59cc9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00007f8f00c5d0d8 in __GI_abort () at abort.c:89
#2  0x00007f8f00c96394 in __libc_message (do_abort=do_abort@entry=1, fmt=fmt@entry=0x7f8f00da4b28 "*** Error in `%s': %s: 0x%s ***\n") at ../sysdeps/posix/libc_fatal.c:175
#3  0x00007f8f00ca266e in malloc_printerr (ptr=<optimized out>, str=0x7f8f00da0c19 "free(): invalid pointer", action=1) at malloc.c:4996
#4  _int_free (av=<optimized out>, p=<optimized out>, have_lock=0) at malloc.c:3840
#5  0x00007f8f01334567 in switch_log_node_free (pnode=pnode@entry=0x7f8eb2b1f158) at src/switch_log.c:136
#6  0x00007f8eeb192a24 in read_packet (listener=listener@entry=0x7f8ebc027898, event=event@entry=0x7f8eb2b1f7f0, timeout=timeout@entry=0) at mod_event_socket.c:1361
#7  0x00007f8eeb1988a0 in listener_run (thread=<optimized out>, obj=0x7f8ebc027898) at mod_event_socket.c:2719
#8  0x00007f8f01544430 in dummy_worker (opaque=0x7f8eb2be4868) at threadproc/unix/thread.c:151
#9  0x00007f8f00ff0182 in start_thread (arg=0x7f8eb2b20700) at pthread_create.c:312
#10 0x00007f8f00d1d47d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111


[
5:44
]
(gdb) bt full
#0  0x00007f8f00c59cc9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
       resultvar = 0
       pid = 18329
       selftid = 18421
#1  0x00007f8f00c5d0d8 in __GI_abort () at abort.c:89
       save_stage = 2
       act = {__sigaction_handler = {sa_handler = 0x0, sa_sigaction = 0x0}, sa_mask = {__val = {0 <repeats 16 times>}}, sa_flags = 0, sa_restorer = 0x0}
       sigs = {__val = {32, 0 <repeats 15 times>}}
#2  0x00007f8f00c96394 in __libc_message (do_abort=do_abort@entry=1, fmt=fmt@entry=0x7f8f00da4b28 "*** Error in `%s': %s: 0x%s ***\n") at ../sysdeps/posix/libc_fatal.c:175
       ap = {{gp_offset = 40, fp_offset = 32654, overflow_arg_area = 0x7f8eb2b1f010, reg_save_area = 0x7f8eb2b1efa0}}
       fd = 2
       on_2 = <optimized out>
       list = <optimized out>
       nlist = <optimized out>
       cp = <optimized out>
       written = <optimized out>
#3  0x00007f8f00ca266e in malloc_printerr (ptr=<optimized out>, str=0x7f8f00da0c19 "free(): invalid pointer", action=1) at malloc.c:4996
       buf = "00007f8ed0036700"
       cp = <optimized out>
#4  _int_free (av=<optimized out>, p=<optimized out>, have_lock=0) at malloc.c:3840
       size = <optimized out>
       fb = <optimized out>
       nextchunk = <optimized out>
       nextsize = <optimized out>
       nextinuse = <optimized out>
       prevsize = <optimized out>
       bck = <optimized out>
       fwd = <optimized out>
       errstr = <optimized out>
       locked = <optimized out>
#5  0x00007f8f01334567 in switch_log_node_free (pnode=pnode@entry=0x7f8eb2b1f158) at src/switch_log.c:136
       node = 0x7f8ed8012ab0
#6  0x00007f8eeb192a24 in read_packet (listener=listener@entry=0x7f8ebc027898, event=event@entry=0x7f8eb2b1f7f0, timeout=timeout@entry=0) at mod_event_socket.c:1361
       dnode = 0x7f8ed8012ab0
       do_sleep = <optimized out>
       mlen = 0
       bytes = 0
       mbuf = 0x7f8ecc1ebfc0 ""
       buf = "Content-Type: log/data\nContent-Length: 88\nLog-Level: 7\nText-Channel: 3\nLog-File: param_hps_strategy.cpp\nLog-Func: retrieve\nLog-Line: 115\nUser-Data: \347@\247\a\n\n\000\n\n\000\065-418f-a6d1-9dc8f48e0cf9\n\n\000\000\071\n\n\000c8f48e0cf9"...
       len = 88
       status = SWITCH_STATUS_BREAK
       count = 0
       elapsed = <optimized out>
       start = 1457966137
       pop = 0x7f8ed8012ab0
       ptr = 0x7f8ecc1ebfc0 ""
       crcount = 0 '\000'
       buf_len = 2048
       channel = 0x0
       clen = 0
       __PRETTY_FUNCTION__ = "read_packet"
       __func__ = "read_packet"
#7  0x00007f8eeb1988a0 in listener_run (thread=<optimized out>, obj=0x7f8ebc027898) at mod_event_socket.c:2719
       listener = 0x7f8ebc027898
       buf = '\000' <repeats 1023 times>
       len = 1024
       status = <optimized out>
       event = 0x0
       reply = "\000OK log level  [7]", '\000' <repeats 493 times>
       session = 0x0
       channel = 0x0
       revent = 0x0
       var = <optimized out>
       locked = 1
       __PRETTY_FUNCTION__ = "listener_run"
       __func__ = "listener_run"
#8  0x00007f8f01544430 in dummy_worker (opaque=0x7f8eb2be4868) at threadproc/unix/thread.c:151
       thread = 0x7f8eb2be4868
#9  0x00007f8f00ff0182 in start_thread (arg=0x7f8eb2b20700) at pthread_create.c:312
       __res = <optimized out>
       pd = 0x7f8eb2b20700
       now = <optimized out>
       unwind_buf = {cancel_jmp_buf = {{jmp_buf = {140250860095232, -640791540281233069, 0, 0, 140250860095936, 140250860095232, 578173923610734931, 577994035108262227}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
       not_first_call = <optimized out>
       pagesize_m1 = <optimized out>
       sp = <optimized out>
       freesize = <optimized out>
       __PRETTY_FUNCTION__ = "start_thread"
#10 0x00007f8f00d1d47d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
No locals




--
Anthony Minessale II       ♬ @anthmfs  ♬ @FreeSWITCH  ♬
http://freeswitch.org/  ☞ http://cluecon.com/  ☞ http://twitter.com/FreeSWITCH
irc.freenode.net #freeswitch ☞ http://freeswitch.org/g+


ClueCon Weekly Development Call 

☎ [url=javascript:_e(%7B%7D,'cvml','sip:888@conference.freeswitch.org');]sip:888@conference.freeswitch.org[/url]  ☎ +19193869900 




https://www.youtube.com/watch?v=9XXgW34t40s
https://www.youtube.com/watch?v=NLaDpGQuZDA









--
mandra
c:410.258.5281
Back to top
mandra at gmail.com
Guest





PostPosted: Wed Mar 16, 2016 4:02 am    Post subject: [Freeswitch-users] Switch_curl Reply with quote

Thanks for responding Anthony. Can you tell me this:
Should curl calls be done in separate thread or is it ok to do them in the main thread of modules?
On Tuesday, March 15, 2016, Chris Mandra <mandra@gmail.com (mandra@gmail.com)> wrote:
Quote:

Should curl calls be done in separate thread or is it ok to do them in the main thread of modules?
On Tuesday, March 15, 2016, Anthony Minessale <[url=javascript:_e(%7B%7D,'cvml','anthony.minessale@gmail.com');]anthony.minessale@gmail.com[/url]> wrote:
Quote:
Curl is used in a few places and is not unstable.  Study some of those mods and maybe you can see how to use it in a typical situation.  Probably its related to memory management or lifecycle of objects you may be using.

On Tuesday, March 15, 2016, Chris Mandra <mandra@gmail.com> wrote:
Quote:
Hey guys, I'm working on a simple media bug module using FS 1.6. When a call comes in I'm calling switch_curl doing an http get. 

In switch_standard_app I use switch_curl and invoke switch_curl_easy_perform and exit after that.
Calling switch_curl seems very unstable. It's crashing free switch most of the time.  Are there any things I should be looking for related to this? I'm wondering if maybe this is a threading issue? Any ideas?
I've included some backtraces


Thanks, chris






(gdb) bt
#0  0x00007f8f00c59cc9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00007f8f00c5d0d8 in __GI_abort () at abort.c:89
#2  0x00007f8f00c96394 in __libc_message (do_abort=do_abort@entry=1, fmt=fmt@entry=0x7f8f00da4b28 "*** Error in `%s': %s: 0x%s ***\n") at ../sysdeps/posix/libc_fatal.c:175
#3  0x00007f8f00ca266e in malloc_printerr (ptr=<optimized out>, str=0x7f8f00da0c19 "free(): invalid pointer", action=1) at malloc.c:4996
#4  _int_free (av=<optimized out>, p=<optimized out>, have_lock=0) at malloc.c:3840
#5  0x00007f8f01334567 in switch_log_node_free (pnode=pnode@entry=0x7f8eb2b1f158) at src/switch_log.c:136
#6  0x00007f8eeb192a24 in read_packet (listener=listener@entry=0x7f8ebc027898, event=event@entry=0x7f8eb2b1f7f0, timeout=timeout@entry=0) at mod_event_socket.c:1361
#7  0x00007f8eeb1988a0 in listener_run (thread=<optimized out>, obj=0x7f8ebc027898) at mod_event_socket.c:2719
#8  0x00007f8f01544430 in dummy_worker (opaque=0x7f8eb2be4868) at threadproc/unix/thread.c:151
#9  0x00007f8f00ff0182 in start_thread (arg=0x7f8eb2b20700) at pthread_create.c:312
#10 0x00007f8f00d1d47d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111


[
5:44
]
(gdb) bt full
#0  0x00007f8f00c59cc9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
       resultvar = 0
       pid = 18329
       selftid = 18421
#1  0x00007f8f00c5d0d8 in __GI_abort () at abort.c:89
       save_stage = 2
       act = {__sigaction_handler = {sa_handler = 0x0, sa_sigaction = 0x0}, sa_mask = {__val = {0 <repeats 16 times>}}, sa_flags = 0, sa_restorer = 0x0}
       sigs = {__val = {32, 0 <repeats 15 times>}}
#2  0x00007f8f00c96394 in __libc_message (do_abort=do_abort@entry=1, fmt=fmt@entry=0x7f8f00da4b28 "*** Error in `%s': %s: 0x%s ***\n") at ../sysdeps/posix/libc_fatal.c:175
       ap = {{gp_offset = 40, fp_offset = 32654, overflow_arg_area = 0x7f8eb2b1f010, reg_save_area = 0x7f8eb2b1efa0}}
       fd = 2
       on_2 = <optimized out>
       list = <optimized out>
       nlist = <optimized out>
       cp = <optimized out>
       written = <optimized out>
#3  0x00007f8f00ca266e in malloc_printerr (ptr=<optimized out>, str=0x7f8f00da0c19 "free(): invalid pointer", action=1) at malloc.c:4996
       buf = "00007f8ed0036700"
       cp = <optimized out>
#4  _int_free (av=<optimized out>, p=<optimized out>, have_lock=0) at malloc.c:3840
       size = <optimized out>
       fb = <optimized out>
       nextchunk = <optimized out>
       nextsize = <optimized out>
       nextinuse = <optimized out>
       prevsize = <optimized out>
       bck = <optimized out>
       fwd = <optimized out>
       errstr = <optimized out>
       locked = <optimized out>
#5  0x00007f8f01334567 in switch_log_node_free (pnode=pnode@entry=0x7f8eb2b1f158) at src/switch_log.c:136
       node = 0x7f8ed8012ab0
#6  0x00007f8eeb192a24 in read_packet (listener=listener@entry=0x7f8ebc027898, event=event@entry=0x7f8eb2b1f7f0, timeout=timeout@entry=0) at mod_event_socket.c:1361
       dnode = 0x7f8ed8012ab0
       do_sleep = <optimized out>
       mlen = 0
       bytes = 0
       mbuf = 0x7f8ecc1ebfc0 ""
       buf = "Content-Type: log/data\nContent-Length: 88\nLog-Level: 7\nText-Channel: 3\nLog-File: param_hps_strategy.cpp\nLog-Func: retrieve\nLog-Line: 115\nUser-Data: \347@\247\a\n\n\000\n\n\000\065-418f-a6d1-9dc8f48e0cf9\n\n\000\000\071\n\n\000c8f48e0cf9"...
       len = 88
       status = SWITCH_STATUS_BREAK
       count = 0
       elapsed = <optimized out>
       start = 1457966137
       pop = 0x7f8ed8012ab0
       ptr = 0x7f8ecc1ebfc0 ""
       crcount = 0 '\000'
       buf_len = 2048
       channel = 0x0
       clen = 0
       __PRETTY_FUNCTION__ = "read_packet"
       __func__ = "read_packet"
#7  0x00007f8eeb1988a0 in listener_run (thread=<optimized out>, obj=0x7f8ebc027898) at mod_event_socket.c:2719
       listener = 0x7f8ebc027898
       buf = '\000' <repeats 1023 times>
       len = 1024
       status = <optimized out>
       event = 0x0
       reply = "\000OK log level  [7]", '\000' <repeats 493 times>
       session = 0x0
       channel = 0x0
       revent = 0x0
       var = <optimized out>
       locked = 1
       __PRETTY_FUNCTION__ = "listener_run"
       __func__ = "listener_run"
#8  0x00007f8f01544430 in dummy_worker (opaque=0x7f8eb2be4868) at threadproc/unix/thread.c:151
       thread = 0x7f8eb2be4868
#9  0x00007f8f00ff0182 in start_thread (arg=0x7f8eb2b20700) at pthread_create.c:312
       __res = <optimized out>
       pd = 0x7f8eb2b20700
       now = <optimized out>
       unwind_buf = {cancel_jmp_buf = {{jmp_buf = {140250860095232, -640791540281233069, 0, 0, 140250860095936, 140250860095232, 578173923610734931, 577994035108262227}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
       not_first_call = <optimized out>
       pagesize_m1 = <optimized out>
       sp = <optimized out>
       freesize = <optimized out>
       __PRETTY_FUNCTION__ = "start_thread"
#10 0x00007f8f00d1d47d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
No locals




--
Anthony Minessale II       ♬ @anthmfs  ♬ @FreeSWITCH  ♬
http://freeswitch.org/  ☞ http://cluecon.com/  ☞ http://twitter.com/FreeSWITCH
irc.freenode.net #freeswitch ☞ http://freeswitch.org/g+


ClueCon Weekly Development Call 

☎ sip:888@conference.freeswitch.org  ☎ +19193869900 




https://www.youtube.com/watch?v=9XXgW34t40s
https://www.youtube.com/watch?v=NLaDpGQuZDA









--
mandra
c:410.258.5281


--
mandra
c:410.258.5281
Back to top
mike at jerris.com
Guest





PostPosted: Wed Mar 16, 2016 3:48 pm    Post subject: [Freeswitch-users] Switch_curl Reply with quote

depends on your needs. The concern would be trying to access those objects across threads potentially could cause issues depending on if they are syncronized or not, easier to just not do it and not have the concern. Anthony is suggesting looking at how we do it in other places. Life cycle could be an issue, are you destroying things too early?
Quote:
On Mar 16, 2016, at 5:00 AM, Chris Mandra <mandra@gmail.com (mandra@gmail.com)> wrote:
Thanks for responding Anthony. Can you tell me this:Should curl calls be done in separate thread or is it ok to do them in the main thread of modules?On Tuesday, March 15, 2016, Chris Mandra <mandra@gmail.com (mandra@gmail.com)> wrote:
Quote:
Should curl calls be done in separate thread or is it ok to do them in the main thread of modules?On Tuesday, March 15, 2016, Anthony Minessale <anthony.minessale@gmail.com> wrote:
Quote:
Curl is used in a few places and is not unstable. Study some of those mods and maybe you can see how to use it in a typical situation. Probably its related to memory management or lifecycle of objects you may be using.On Tuesday, March 15, 2016, Chris Mandra <mandra@gmail.com> wrote:
Quote:
Hey guys, I'm working on a simple media bug module using FS 1.6. When a call comes in I'm calling switch_curl doing an http get.

In switch_standard_app I use switch_curl and invoke switch_curl_easy_perform and exit after that.
Calling switch_curl seems very unstable. It's crashing free switch most of the time. Are there any things I should be looking for related to this? I'm wondering if maybe this is a threading issue? Any ideas?
I've included some backtraces

Thanks, chris




(gdb) bt
#0 0x00007f8f00c59cc9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1 0x00007f8f00c5d0d8 in __GI_abort () at abort.c:89
#2 0x00007f8f00c96394 in __libc_message (do_abort=do_abort@entry=1, fmt=fmt@entry=0x7f8f00da4b28 "*** Error in `%s': %s: 0x%s ***\n") at ../sysdeps/posix/libc_fatal.c:175
#3 0x00007f8f00ca266e in malloc_printerr (ptr=<optimized out>, str=0x7f8f00da0c19 "free(): invalid pointer", action=1) at malloc.c:4996
#4 _int_free (av=<optimized out>, p=<optimized out>, have_lock=0) at malloc.c:3840
#5 0x00007f8f01334567 in switch_log_node_free (pnode=pnode@entry=0x7f8eb2b1f158) at src/switch_log.c:136
#6 0x00007f8eeb192a24 in read_packet (listener=listener@entry=0x7f8ebc027898, event=event@entry=0x7f8eb2b1f7f0, timeout=timeout@entry=0) at mod_event_socket.c:1361
#7 0x00007f8eeb1988a0 in listener_run (thread=<optimized out>, obj=0x7f8ebc027898) at mod_event_socket.c:2719
#8 0x00007f8f01544430 in dummy_worker (opaque=0x7f8eb2be4868) at threadproc/unix/thread.c:151
#9 0x00007f8f00ff0182 in start_thread (arg=0x7f8eb2b20700) at pthread_create.c:312
#10 0x00007f8f00d1d47d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

[
5:44
]
(gdb) bt full
#0 0x00007f8f00c59cc9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
resultvar = 0
pid = 18329
selftid = 18421
#1 0x00007f8f00c5d0d8 in __GI_abort () at abort.c:89
save_stage = 2
act = {__sigaction_handler = {sa_handler = 0x0, sa_sigaction = 0x0}, sa_mask = {__val = {0 <repeats 16 times>}}, sa_flags = 0, sa_restorer = 0x0}
sigs = {__val = {32, 0 <repeats 15 times>}}
#2 0x00007f8f00c96394 in __libc_message (do_abort=do_abort@entry=1, fmt=fmt@entry=0x7f8f00da4b28 "*** Error in `%s': %s: 0x%s ***\n") at ../sysdeps/posix/libc_fatal.c:175
ap = {{gp_offset = 40, fp_offset = 32654, overflow_arg_area = 0x7f8eb2b1f010, reg_save_area = 0x7f8eb2b1efa0}}
fd = 2
on_2 = <optimized out>
list = <optimized out>
nlist = <optimized out>
cp = <optimized out>
written = <optimized out>
#3 0x00007f8f00ca266e in malloc_printerr (ptr=<optimized out>, str=0x7f8f00da0c19 "free(): invalid pointer", action=1) at malloc.c:4996
buf = "00007f8ed0036700"
cp = <optimized out>
#4 _int_free (av=<optimized out>, p=<optimized out>, have_lock=0) at malloc.c:3840
size = <optimized out>
fb = <optimized out>
nextchunk = <optimized out>
nextsize = <optimized out>
nextinuse = <optimized out>
prevsize = <optimized out>
bck = <optimized out>
fwd = <optimized out>
errstr = <optimized out>
locked = <optimized out>
#5 0x00007f8f01334567 in switch_log_node_free (pnode=pnode@entry=0x7f8eb2b1f158) at src/switch_log.c:136
node = 0x7f8ed8012ab0
#6 0x00007f8eeb192a24 in read_packet (listener=listener@entry=0x7f8ebc027898, event=event@entry=0x7f8eb2b1f7f0, timeout=timeout@entry=0) at mod_event_socket.c:1361
dnode = 0x7f8ed8012ab0
do_sleep = <optimized out>
mlen = 0
bytes = 0
mbuf = 0x7f8ecc1ebfc0 ""
buf = "Content-Type: log/data\nContent-Length: 88\nLog-Level: 7\nText-Channel: 3\nLog-File: param_hps_strategy.cpp\nLog-Func: retrieve\nLog-Line: 115\nUser-Data: \347@\247\a\n\n\000\n\n\000\065-418f-a6d1-9dc8f48e0cf9\n\n\000\000\071\n\n\000c8f48e0cf9"...
len = 88
status = SWITCH_STATUS_BREAK
count = 0
elapsed = <optimized out>
start = 1457966137
pop = 0x7f8ed8012ab0
ptr = 0x7f8ecc1ebfc0 ""
crcount = 0 '\000'
buf_len = 2048
channel = 0x0
clen = 0
__PRETTY_FUNCTION__ = "read_packet"
__func__ = "read_packet"
#7 0x00007f8eeb1988a0 in listener_run (thread=<optimized out>, obj=0x7f8ebc027898) at mod_event_socket.c:2719
listener = 0x7f8ebc027898
buf = '\000' <repeats 1023 times>
len = 1024
status = <optimized out>
event = 0x0
reply = "\000OK log level [7]", '\000' <repeats 493 times>
session = 0x0
channel = 0x0
revent = 0x0
var = <optimized out>
locked = 1
__PRETTY_FUNCTION__ = "listener_run"
__func__ = "listener_run"
#8 0x00007f8f01544430 in dummy_worker (opaque=0x7f8eb2be4868) at threadproc/unix/thread.c:151
thread = 0x7f8eb2be4868
#9 0x00007f8f00ff0182 in start_thread (arg=0x7f8eb2b20700) at pthread_create.c:312
__res = <optimized out>
pd = 0x7f8eb2b20700
now = <optimized out>
unwind_buf = {cancel_jmp_buf = {{jmp_buf = {140250860095232, -640791540281233069, 0, 0, 140250860095936, 140250860095232, 578173923610734931, 577994035108262227}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
not_first_call = <optimized out>
pagesize_m1 = <optimized out>
sp = <optimized out>
freesize = <optimized out>
__PRETTY_FUNCTION__ = "start_thread"
#10 0x00007f8f00d1d47d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
No locals



Back to top
anthony.minessale at g...
Guest





PostPosted: Wed Mar 16, 2016 3:55 pm    Post subject: [Freeswitch-users] Switch_curl Reply with quote

If you use more threads you just need to make sure the objects are properly scoped.  For instance, if you want to use a session from the other thread you need to read lock it for the life of the thread.  Objects shared need to be dynamically allocated and properly mutexed etc.

Whatever thread you call curl from will be used for the whole curl operation.

On Wednesday, March 16, 2016, Michael Jerris <mike@jerris.com (mike@jerris.com)> wrote:
Quote:
depends on your needs.  The concern would be trying to access those objects across threads potentially could cause issues depending on if they are syncronized or not, easier to just not do it and not have the concern.  Anthony is suggesting looking at how we do it in other places.  Life cycle could be an issue, are you destroying things too early?
Quote:
On Mar 16, 2016, at 5:00 AM, Chris Mandra <[url=javascript:_e(%7B%7D,'cvml','mandra@gmail.com');]mandra@gmail.com[/url]> wrote:

Thanks for responding Anthony. Can you tell me this:Should curl calls be done in separate thread or is it ok to do them in the main thread of modules?On Tuesday, March 15, 2016, Chris Mandra <[url=javascript:_e(%7B%7D,'cvml','mandra@gmail.com');]mandra@gmail.com[/url]> wrote:
Quote:

Should curl calls be done in separate thread or is it ok to do them in the main thread of modules?
On Tuesday, March 15, 2016, Anthony Minessale <anthony.minessale@gmail.com> wrote:
Quote:
Curl is used in a few places and is not unstable.  Study some of those mods and maybe you can see how to use it in a typical situation.  Probably its related to memory management or lifecycle of objects you may be using.

On Tuesday, March 15, 2016, Chris Mandra <mandra@gmail.com> wrote:
Quote:
Hey guys, I'm working on a simple media bug module using FS 1.6. When a call comes in I'm calling switch_curl doing an http get. 

In switch_standard_app I use switch_curl and invoke switch_curl_easy_perform and exit after that.
Calling switch_curl seems very unstable. It's crashing free switch most of the time.  Are there any things I should be looking for related to this? I'm wondering if maybe this is a threading issue? Any ideas?
I've included some backtraces


Thanks, chris






(gdb) bt
#0  0x00007f8f00c59cc9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00007f8f00c5d0d8 in __GI_abort () at abort.c:89
#2  0x00007f8f00c96394 in __libc_message (do_abort=do_abort@entry=1, fmt=fmt@entry=0x7f8f00da4b28 "*** Error in `%s': %s: 0x%s ***\n") at ../sysdeps/posix/libc_fatal.c:175
#3  0x00007f8f00ca266e in malloc_printerr (ptr=<optimized out>, str=0x7f8f00da0c19 "free(): invalid pointer", action=1) at malloc.c:4996
#4  _int_free (av=<optimized out>, p=<optimized out>, have_lock=0) at malloc.c:3840
#5  0x00007f8f01334567 in switch_log_node_free (pnode=pnode@entry=0x7f8eb2b1f158) at src/switch_log.c:136
#6  0x00007f8eeb192a24 in read_packet (listener=listener@entry=0x7f8ebc027898, event=event@entry=0x7f8eb2b1f7f0, timeout=timeout@entry=0) at mod_event_socket.c:1361
#7  0x00007f8eeb1988a0 in listener_run (thread=<optimized out>, obj=0x7f8ebc027898) at mod_event_socket.c:2719
#8  0x00007f8f01544430 in dummy_worker (opaque=0x7f8eb2be4868) at threadproc/unix/thread.c:151
#9  0x00007f8f00ff0182 in start_thread (arg=0x7f8eb2b20700) at pthread_create.c:312
#10 0x00007f8f00d1d47d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111


[
5:44
]
(gdb) bt full
#0  0x00007f8f00c59cc9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
       resultvar = 0
       pid = 18329
       selftid = 18421
#1  0x00007f8f00c5d0d8 in __GI_abort () at abort.c:89
       save_stage = 2
       act = {__sigaction_handler = {sa_handler = 0x0, sa_sigaction = 0x0}, sa_mask = {__val = {0 <repeats 16 times>}}, sa_flags = 0, sa_restorer = 0x0}
       sigs = {__val = {32, 0 <repeats 15 times>}}
#2  0x00007f8f00c96394 in __libc_message (do_abort=do_abort@entry=1, fmt=fmt@entry=0x7f8f00da4b28 "*** Error in `%s': %s: 0x%s ***\n") at ../sysdeps/posix/libc_fatal.c:175
       ap = {{gp_offset = 40, fp_offset = 32654, overflow_arg_area = 0x7f8eb2b1f010, reg_save_area = 0x7f8eb2b1efa0}}
       fd = 2
       on_2 = <optimized out>
       list = <optimized out>
       nlist = <optimized out>
       cp = <optimized out>
       written = <optimized out>
#3  0x00007f8f00ca266e in malloc_printerr (ptr=<optimized out>, str=0x7f8f00da0c19 "free(): invalid pointer", action=1) at malloc.c:4996
       buf = "00007f8ed0036700"
       cp = <optimized out>
#4  _int_free (av=<optimized out>, p=<optimized out>, have_lock=0) at malloc.c:3840
       size = <optimized out>
       fb = <optimized out>
       nextchunk = <optimized out>
       nextsize = <optimized out>
       nextinuse = <optimized out>
       prevsize = <optimized out>
       bck = <optimized out>
       fwd = <optimized out>
       errstr = <optimized out>
       locked = <optimized out>
#5  0x00007f8f01334567 in switch_log_node_free (pnode=pnode@entry=0x7f8eb2b1f158) at src/switch_log.c:136
       node = 0x7f8ed8012ab0
#6  0x00007f8eeb192a24 in read_packet (listener=listener@entry=0x7f8ebc027898, event=event@entry=0x7f8eb2b1f7f0, timeout=timeout@entry=0) at mod_event_socket.c:1361
       dnode = 0x7f8ed8012ab0
       do_sleep = <optimized out>
       mlen = 0
       bytes = 0
       mbuf = 0x7f8ecc1ebfc0 ""
       buf = "Content-Type: log/data\nContent-Length: 88\nLog-Level: 7\nText-Channel: 3\nLog-File: param_hps_strategy.cpp\nLog-Func: retrieve\nLog-Line: 115\nUser-Data: \347@\247\a\n\n\000\n\n\000\065-418f-a6d1-9dc8f48e0cf9\n\n\000\000\071\n\n\000c8f48e0cf9"...
       len = 88
       status = SWITCH_STATUS_BREAK
       count = 0
       elapsed = <optimized out>
       start = 1457966137
       pop = 0x7f8ed8012ab0
       ptr = 0x7f8ecc1ebfc0 ""
       crcount = 0 '\000'
       buf_len = 2048
       channel = 0x0
       clen = 0
       __PRETTY_FUNCTION__ = "read_packet"
       __func__ = "read_packet"
#7  0x00007f8eeb1988a0 in listener_run (thread=<optimized out>, obj=0x7f8ebc027898) at mod_event_socket.c:2719
       listener = 0x7f8ebc027898
       buf = '\000' <repeats 1023 times>
       len = 1024
       status = <optimized out>
       event = 0x0
       reply = "\000OK log level  [7]", '\000' <repeats 493 times>
       session = 0x0
       channel = 0x0
       revent = 0x0
       var = <optimized out>
       locked = 1
       __PRETTY_FUNCTION__ = "listener_run"
       __func__ = "listener_run"
#8  0x00007f8f01544430 in dummy_worker (opaque=0x7f8eb2be4868) at threadproc/unix/thread.c:151
       thread = 0x7f8eb2be4868
#9  0x00007f8f00ff0182 in start_thread (arg=0x7f8eb2b20700) at pthread_create.c:312
       __res = <optimized out>
       pd = 0x7f8eb2b20700
       now = <optimized out>
       unwind_buf = {cancel_jmp_buf = {{jmp_buf = {140250860095232, -640791540281233069, 0, 0, 140250860095936, 140250860095232, 578173923610734931, 577994035108262227}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
       not_first_call = <optimized out>
       pagesize_m1 = <optimized out>
       sp = <optimized out>
       freesize = <optimized out>
       __PRETTY_FUNCTION__ = "start_thread"
#10 0x00007f8f00d1d47d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
No locals











--
Anthony Minessale II       ♬ @anthmfs  ♬ @FreeSWITCH  ♬
http://freeswitch.org/  ☞ http://cluecon.com/  ☞ http://twitter.com/FreeSWITCH
irc.freenode.net #freeswitch ☞ http://freeswitch.org/g+


ClueCon Weekly Development Call 

☎ sip:888@conference.freeswitch.org ([email]sip%3A888@conference.freeswitch.org[/email])  ☎ +19193869900 




https://www.youtube.com/watch?v=9XXgW34t40s
https://www.youtube.com/watch?v=NLaDpGQuZDA
Back to top
Display posts from previous:   
Post new topic   Reply to topic    VoIP Mailing List Archives Forum Index -> freeSWITCH Users All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

VoiceMeUp - Corporate & Wholesale VoIP Services