[Home]

Summary:ASTERISK-13589: CURL() function crashes in /trunk
Reporter:David Van Ginneken (davevg)Labels:
Date Opened:2009-02-16 16:06:33.000-0600Date Closed:2009-02-17 15:16:54.000-0600
Priority:CriticalRegression?No
Status:Closed/CompleteComponents:Functions/func_curl
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) malloc_debug.txt
( 1) valgrind.txt
( 2) valgrind2.txt
( 3) valgrind3.txt
Description:With this stripped down dialplan, asterisk crashes in /trunk version.
exten => 77,1,Answer()
exten => 77,n,Set(foo=${CURL(http://192.168.175.100/push)})

I've also tried a known working link from the last round of testing I did and have the same issue:
;exten => 77,n,Set(foo=${CURL(http://192.168.175.97/nascar/test.pl)})
;exten => 77,n,Set(foo=${CURL(http://www.google.com)})

Here is the bug with the testing that was done last time.
http://bugs.digium.com/bug_view_page.php?bug_id=12920


(gdb) bt
#0  0x00596402 in __kernel_vsyscall ()
#1  0x003b8d10 in raise () from /lib/libc.so.6
#2  0x003ba621 in abort () from /lib/libc.so.6
#3  0x003f0e5b in __libc_message () from /lib/libc.so.6
#4  0x003fb5be in _int_realloc () from /lib/libc.so.6
ASTERISK-1  0x003fc4dd in realloc () from /lib/libc.so.6
ASTERISK-2  0x081485ec in _ast_realloc (p=0x9731710, len=44, file=0x81a9954 "/usr/src/asterisk-trunk/include/asterisk/strings.h", lineno=540,
   func=0x81a9987 "ast_str_make_space") at /usr/src/asterisk-trunk/include/asterisk/utils.h:493
ASTERISK-3  0x08148b7b in ast_str_make_space (buf=0x298bb1c, new_len=32) at /usr/src/asterisk-trunk/include/asterisk/strings.h:518
ASTERISK-4  0x0813b629 in __ast_str_helper2 (buf=0x298bb1c, maxlen=0, src=0x985e83c "nt IP Telephone HTTPd", maxsrc=21, append=1, escapecommas=0) at strings.c:135
ASTERISK-5  0x08148d05 in ast_str_append_substr (buf=0x298bb1c, maxlen=0, src=0x985e82c "Polycom SoundPoint IP Telephone HTTPd", maxsrc=37)
   at /usr/src/asterisk-trunk/include/asterisk/strings.h:736
ASTERISK-6 0x03f2912b in WriteMemoryCallback (ptr=0x985e82c, size=1, nmemb=37, data=0x298bb1c) at func_curl.c:359
ASTERISK-7 0x06601c54 in Curl_client_write () from /usr/lib/libcurl.so.3
ASTERISK-8 0x066171f1 in Curl_readwrite () from /usr/lib/libcurl.so.3
ASTERISK-9 0x06617bbe in Curl_perform () from /usr/lib/libcurl.so.3
ASTERISK-10 0x06617fc9 in curl_easy_perform () from /usr/lib/libcurl.so.3
ASTERISK-11 0x03f295d6 in acf_curl_exec (chan=0x9857a68, cmd=0x298bb70 "CURL", info=0x298bb75 "http://192.168.175.100/push", buf=0x298bc20 "", len=4096)
   at func_curl.c:456
ASTERISK-12 0x080f4a90 in ast_func_read (chan=0x9857a68, function=0x298cc30 "CURL(http://192.168.175.100/push)", workspace=0x298bc20 "", len=4096) at pbx.c:3316
ASTERISK-13 0x080f4fd1 in pbx_substitute_variables_helper_full (c=0x9857a68, headp=0x9857b80, cp1=0x98f60a0 "foo=${CURL(http://192.168.175.100/push)}",
   cp2=0x298fe9c "", count=8187, used=0x298dd34) at pbx.c:3451
ASTERISK-14 0x080f5575 in pbx_substitute_variables_helper (c=0x9857a68, cp1=0x98f60a0 "foo=${CURL(http://192.168.175.100/push)}", cp2=0x298fe98 "foo=", count=8191)
   at pbx.c:3546
ASTERISK-15 0x080f5655 in pbx_substitute_variables (passdata=0x298fe98 "foo=", datalen=8192, c=0x9857a68, e=0x98fac50) at pbx.c:3569
ASTERISK-16 0x080f587d in pbx_extension_helper (c=0x9857a68, con=0x0, context=0x9857cd6 "default", exten=0x9857d26 "77", priority=2, label=0x0,
   callerid=0x9837380 "1223", action=E_SPAWN, found=0x29922ec, combined_find_spawn=1) at pbx.c:3631
ASTERISK-17 0x080f6e23 in ast_spawn_extension (c=0x9857a68, context=0x9857cd6 "default", exten=0x9857d26 "77", priority=2, callerid=0x9837380 "1223", found=0x29922ec,
   combined_find_spawn=1) at pbx.c:4096
ASTERISK-18 0x080f74af in __ast_pbx_run (c=0x9857a68, args=0x0) at pbx.c:4186
ASTERISK-19 0x080f8937 in pbx_thread (data=0x9857a68) at pbx.c:4473
ASTERISK-20 0x08149697 in dummy_start (data=0x9762ad8) at utils.c:968
ASTERISK-21 0x0030845b in start_thread () from /lib/libpthread.so.0
ASTERISK-22 0x00460e5e in clone () from /lib/libc.so.6


****** ADDITIONAL INFORMATION ******

I'm working on trying to give an example of using the curl function natively in asterisk to initiate push requests to a Polycom phone. And was trying to do the following.

exten => 77,1,Answer()
exten => 77,n,Set(CURLOPT(userpwd)="btw:btw")
exten => 77,n,Set(foo=${CURL(http://192.168.175.100/push,"<PolycomIPPhone><URL Priority=\"critical\">spipx.pl?dialstring=1220</URL></PolycomIPPhone>")})
exten => 77,n,Hangup

To see if the curl function as it stands would be able to negotiate the Digest authentication.


(gdb) bt full
#0  0x00596402 in __kernel_vsyscall ()
No symbol table info available.
#1  0x003b8d10 in raise () from /lib/libc.so.6
No symbol table info available.
#2  0x003ba621 in abort () from /lib/libc.so.6
No symbol table info available.
#3  0x003f0e5b in __libc_message () from /lib/libc.so.6
No symbol table info available.
#4  0x003fb5be in _int_realloc () from /lib/libc.so.6
No symbol table info available.
ASTERISK-1  0x003fc4dd in realloc () from /lib/libc.so.6
No symbol table info available.
ASTERISK-2  0x081485ec in _ast_realloc (p=0x9731710, len=44, file=0x81a9954 "/usr/src/asterisk-trunk/include/asterisk/strings.h", lineno=540,
   func=0x81a9987 "ast_str_make_space") at /usr/src/asterisk-trunk/include/asterisk/utils.h:493
       newp = (void *) 0x9858248
       __PRETTY_FUNCTION__ = "_ast_realloc"
ASTERISK-3  0x08148b7b in ast_str_make_space (buf=0x298bb1c, new_len=32) at /usr/src/asterisk-trunk/include/asterisk/strings.h:518
       old_buf = (struct ast_str *) 0x9731710
       __PRETTY_FUNCTION__ = "ast_str_make_space"
ASTERISK-4  0x0813b629 in __ast_str_helper2 (buf=0x298bb1c, maxlen=0, src=0x985e83c "nt IP Telephone HTTPd", maxsrc=21, append=1, escapecommas=0) at strings.c:135
       old = 16
       dynamic = 1
       ptr = 0x9731746 "llowable datatypes are:\n    <enum>all</enum>\n    <enum>num</enum>\n    <enum>ANI</enum>\n    <enum>DNID</enum>\n    <enum>RDNIS</enum>\n    <enum>pres</enum>\n    <enum>ton</enum>\nCID\n    Optional Caller*I"...
ASTERISK-5  0x08148d05 in ast_str_append_substr (buf=0x298bb1c, maxlen=0, src=0x985e82c "Polycom SoundPoint IP Telephone HTTPd", maxsrc=37)
   at /usr/src/asterisk-trunk/include/asterisk/strings.h:736
No locals.
ASTERISK-6 0x03f2912b in WriteMemoryCallback (ptr=0x985e82c, size=1, nmemb=37, data=0x298bb1c) at func_curl.c:359
       realsize = 37
       pstr = (struct ast_str **) 0x298bb1c
       __PRETTY_FUNCTION__ = "WriteMemoryCallback"
ASTERISK-7 0x06601c54 in Curl_client_write () from /usr/lib/libcurl.so.3
No symbol table info available.
ASTERISK-8 0x066171f1 in Curl_readwrite () from /usr/lib/libcurl.so.3
---Type <return> to continue, or q <return> to quit---
No symbol table info available.
ASTERISK-9 0x06617bbe in Curl_perform () from /usr/lib/libcurl.so.3
No symbol table info available.
ASTERISK-10 0x06617fc9 in curl_easy_perform () from /usr/lib/libcurl.so.3
No symbol table info available.
ASTERISK-11 0x03f295d6 in acf_curl_exec (chan=0x9857a68, cmd=0x298bb70 "CURL", info=0x298bb75 "http://192.168.175.100/push", buf=0x298bc20 "", len=4096)
   at func_curl.c:456
       str = (struct ast_str *) 0x9731710
       ret = -1
       args = {argc = 1, argv = 0x298bb14, url = 0x298bb75 "http://192.168.175.100/push", postdata = 0x0}
       curl = (CURL **) 0x978ba58
       cur = (struct curl_settings *) 0x0
       store = (struct ast_datastore *) 0x0
       hashcompat = 0
       list = (struct global_curl_info *) 0x0
       __PRETTY_FUNCTION__ = "acf_curl_exec"
ASTERISK-12 0x080f4a90 in ast_func_read (chan=0x9857a68, function=0x298cc30 "CURL(http://192.168.175.100/push)", workspace=0x298bc20 "", len=4096) at pbx.c:3316
       res = 0
       u = (struct ast_module_user *) 0x97c99f0
       copy = 0x298bb70 "CURL"
       args = 0x298bb75 "http://192.168.175.100/push"
       acfptr = (struct ast_custom_function *) 0x3f2b720
       __PRETTY_FUNCTION__ = "ast_func_read"
ASTERISK-13 0x080f4fd1 in pbx_substitute_variables_helper_full (c=0x9857a68, headp=0x9857b80, cp1=0x98f60a0 "foo=${CURL(http://192.168.175.100/push)}",
   cp2=0x298fe9c "", count=8187, used=0x298dd34) at pbx.c:3451
       cp4 = 0x0
       tmp = 0x98f60a0 "foo=${CURL(http://192.168.175.100/push)}"
       whereweare = 0x98f60c8 ""
       orig_cp2 = 0x298fe98 "foo="
       length = 0
       offset = 0
       offset2 = 2147483647
       isfunction = 1
       workspace = 0x298bc20 ""
---Type <return> to continue, or q <return> to quit---
       ltmp = 0x0
       var = 0x298cc30 "CURL(http://192.168.175.100/push)"
       nextvar = 0x98f60a4 "${CURL(http://192.168.175.100/push)}"
       nextexp = 0x0
       nextthing = 0x98f60a4 "${CURL(http://192.168.175.100/push)}"
       vars = 0x298cc30 "CURL(http://192.168.175.100/push)"
       vare = 0x98f60c8 ""
       pos = 4
       brackets = 0
       needsub = 0
       len = 33
       __PRETTY_FUNCTION__ = "pbx_substitute_variables_helper_full"
ASTERISK-14 0x080f5575 in pbx_substitute_variables_helper (c=0x9857a68, cp1=0x98f60a0 "foo=${CURL(http://192.168.175.100/push)}", cp2=0x298fe98 "foo=", count=8191)
   at pbx.c:3546
       used = 43592592
ASTERISK-15 0x080f5655 in pbx_substitute_variables (passdata=0x298fe98 "foo=", datalen=8192, c=0x9857a68, e=0x98fac50) at pbx.c:3569
       tmp = 0x98f60a4 "${CURL(http://192.168.175.100/push)}"
ASTERISK-16 0x080f587d in pbx_extension_helper (c=0x9857a68, con=0x0, context=0x9857cd6 "default", exten=0x9857d26 "77", priority=2, label=0x0,
   callerid=0x9837380 "1223", action=E_SPAWN, found=0x29922ec, combined_find_spawn=1) at pbx.c:3631
       e = (struct ast_exten *) 0x98fac50
       app = (struct ast_app *) 0x9732750
       res = 43592592
       q = {incstack = {0x0 <repeats 128 times>}, stacklen = 0, status = 5, swo = 0x0, data = 0x0, foundcontext = 0x9857cd6 "default"}
       passdata = "foo=", '\0' <repeats 8187 times>
       matching_action = 0
       __PRETTY_FUNCTION__ = "pbx_extension_helper"
ASTERISK-17 0x080f6e23 in ast_spawn_extension (c=0x9857a68, context=0x9857cd6 "default", exten=0x9857d26 "77", priority=2, callerid=0x9837380 "1223", found=0x29922ec,
   combined_find_spawn=1) at pbx.c:4096
No locals.
ASTERISK-18 0x080f74af in __ast_pbx_run (c=0x9857a68, args=0x0) at pbx.c:4186
       digit = 0
       invalid = 0
       timeout = 0
       dst_exten = '\0' <repeats 192 times>, "\021\216?", '\0' <repeats 57 times>, "\020\000\000"
---Type <return> to continue, or q <return> to quit---
       pos = 0
       found = 1
       res = 0
       autoloopflag = 0
       error = 0
       __PRETTY_FUNCTION__ = "__ast_pbx_run"
ASTERISK-19 0x080f8937 in pbx_thread (data=0x9857a68) at pbx.c:4473
       c = (struct ast_channel *) 0x9857a68
ASTERISK-20 0x08149697 in dummy_start (data=0x9762ad8) at utils.c:968
       __cancel_buf = {__cancel_jmp_buf = {{__cancel_jmp_buf = {3239924, 0, 43592592, 43590584, -364315454, -523941387}, __mask_was_saved = 0}}, __pad = {
   0x2992470, 0x0, 0x0, 0x0}}
       __cancel_routine = (void (*)(void *)) 0x807348f <ast_unregister_thread>
       __cancel_arg = (void *) 0x2992b90
       not_first_call = 0
       ret = (void *) 0x0
       a = {start_routine = 0x80f8918 <pbx_thread>, data = 0x9857a68,
 name = 0x97d5718 "pbx_thread", ' ' <repeats 11 times>, "started at [ 4494] pbx.c ast_pbx_start()"}
ASTERISK-21 0x0030845b in start_thread () from /lib/libpthread.so.0
No symbol table info available.
ASTERISK-22 0x00460e5e in clone () from /lib/libc.so.6
No symbol table info available.
Comments:By: Mark Michelson (mmichelson) 2009-02-16 16:32:58.000-0600

Assigning to Corydon76. I think this may have arisen as a result of the merge of ast_str opacity.



By: Tilghman Lesher (tilghman) 2009-02-16 17:01:59.000-0600

Please follow the instructions in doc/valgrind.txt.

By: David Van Ginneken (davevg) 2009-02-16 17:12:35.000-0600

Uploaded valgrind.txt, malloc_debug.txt was empty

edit, I probably didn't enable malloc_debug in the compile options for asterisk, going to recompile with it and rerun the valgrind.



By: Digium Subversion (svnbot) 2009-02-16 17:48:55.000-0600

Repository: asterisk
Revision: 176360

U   trunk/main/strings.c

------------------------------------------------------------------------
r176360 | tilghman | 2009-02-16 17:48:54 -0600 (Mon, 16 Feb 2009) | 4 lines

Might want to update the buffer pointer after a realloc (or we crash)
(closes issue ASTERISK-13589)
Reported by: davevg

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=176360

By: Digium Subversion (svnbot) 2009-02-16 17:49:44.000-0600

Repository: asterisk
Revision: 176361

_U  branches/1.6.1/

------------------------------------------------------------------------
r176361 | tilghman | 2009-02-16 17:49:44 -0600 (Mon, 16 Feb 2009) | 10 lines

Blocked revisions 176360 via svnmerge

........
 r176360 | tilghman | 2009-02-16 17:48:54 -0600 (Mon, 16 Feb 2009) | 4 lines
 
 Might want to update the buffer pointer after a realloc (or we crash)
 (closes issue ASTERISK-13589)
  Reported by: davevg
........

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=176361

By: David Van Ginneken (davevg) 2009-02-17 08:24:24.000-0600

Still seeing a crash at the same point in the dialplan with svn version Asterisk SVN-trunk-r176459.  I have another crash I encountered when the server was idle related to IMAP voicemail, but I'll open a new bug for it.

By: Digium Subversion (svnbot) 2009-02-17 12:49:44.000-0600

Repository: asterisk
Revision: 176592

U   trunk/funcs/func_odbc.c
U   trunk/res/res_odbc.c

------------------------------------------------------------------------
r176592 | tilghman | 2009-02-17 12:49:43 -0600 (Tue, 17 Feb 2009) | 4 lines

Add assertions in the quest to track down a refcount leak.
(closes issue ASTERISK-13589)
Reported by: davevg

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=176592

By: Digium Subversion (svnbot) 2009-02-17 15:16:53.000-0600

Repository: asterisk
Revision: 176644

_U  branches/1.6.1/
U   branches/1.6.1/channels/chan_local.c
U   branches/1.6.1/res/res_odbc.c

------------------------------------------------------------------------
r176644 | tilghman | 2009-02-17 15:16:53 -0600 (Tue, 17 Feb 2009) | 21 lines

Merged revisions 176592,176642 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

........
 r176592 | tilghman | 2009-02-17 12:49:20 -0600 (Tue, 17 Feb 2009) | 4 lines
 
 Add assertions in the quest to track down a refcount leak.
 (closes issue ASTERISK-13589)
  Reported by: davevg
........
 r176642 | tilghman | 2009-02-17 15:14:18 -0600 (Tue, 17 Feb 2009) | 8 lines
 
 Prior to masquerade, move the group definitions to the channel performing the
 masq, so that the group count lingers past the bridge.
 (closes issue ASTERISK-13397)
  Reported by: kowalma
  Patches:
        20090216__bug14275.diff.txt uploaded by Corydon76 (license 14)
  Tested by: kowalma
........

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=176644