[Home]

Summary:ASTERISK-14055: tab completion sefault when using with CLI aliases
Reporter:Clod Patry (junky)Labels:
Date Opened:2009-05-02 14:48:43Date Closed:2009-05-06 09:37:35
Priority:CriticalRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:when using the default cli_aliases.conf, if you enable the 3 templates (asterisk12,asterisk14,individual_custom), if you hit tab twice on a CLI alias, its segfault.


ex.
*CLI> mute<tab><tab>
or
*CLI> dial
dialplan  dial      
*CLI> dial<space>
dialplan  dial      
*CLI> dial <tab>Segmentation fault (core dumped)


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

it seems to be a problem of recursion:

#0  0xb7dc8250 in dl_iterate_phdr () from /lib/tls/i686/cmov/libc.so.6
#1  0xb7dcb735 in _Unwind_Find_FDE () from /lib/tls/i686/cmov/libc.so.6
#2  0xb7ac15dd in ?? () from /lib/libgcc_s.so.1
#3  0xb7ac1e18 in ?? () from /lib/libgcc_s.so.1
#4  0xb7ac1f61 in _Unwind_Backtrace () from /lib/libgcc_s.so.1
ASTERISK-1  0xb7da29f8 in backtrace () from /lib/tls/i686/cmov/libc.so.6
ASTERISK-2  0x081169cf in ast_bt_get_addresses (bt=0x8f2af74) at logger.c:1135
ASTERISK-3  0x08086fd7 in __ast_pthread_mutex_lock (filename=0x81ca0d8 "astobj2.c", lineno=652, func=0x81ca54e "internal_ao2_callback", mutex_name=0x81ca530 "c",
   t=0x8f2aed0) at /usr/src/asterisk-trunk/include/asterisk/lock.h:511
ASTERISK-4  0x08086e8f in __ao2_lock (user_data=0x8f2b508, file=0x81ca0d8 "astobj2.c", func=0x81ca54e "internal_ao2_callback", line=652, var=0x81ca530 "c")
   at astobj2.c:165
ASTERISK-5  0x08088abb in internal_ao2_callback (c=0x8f2b508, flags=OBJ_POINTER, cb_fn=0xb399bc77, arg=0xbf2ce538, data=0x0, type=DEFAULT, tag=0x0, file=0x0,
   line=0, funcname=0x0) at astobj2.c:652
ASTERISK-6 0x08088eac in __ao2_callback (c=0x8f2b508, flags=OBJ_POINTER, cb_fn=0xb399bc77 <alias_cmp_cb>, arg=0xbf2ce538) at astobj2.c:730
ASTERISK-7 0x08088fc8 in __ao2_find (c=0x8f2b508, arg=0xbf2ce538, flags=OBJ_POINTER) at astobj2.c:757
ASTERISK-8 0xb399bd81 in cli_alias_passthrough (e=0x8f54c18, cmd=-3, a=0xbf2ce73c) at res_clialiases.c:90
ASTERISK-9 0x080c0378 in __ast_cli_generator (text=0x8f54c90 "console active", word=0x8c10065 "", state=0, lock=1) at cli.c:2295
ASTERISK-10 0x080c043f in ast_cli_generator (text=0x8f54c90 "console active", word=0x8c10065 "", state=0) at cli.c:2309
ASTERISK-11 0xb399bf5d in cli_alias_passthrough (e=0x8f54c18, cmd=-3, a=0xbf2cea6c) at res_clialiases.c:106
ASTERISK-12 0x080c0378 in __ast_cli_generator (text=0x8f54c90 "console active", word=0x8c10065 "", state=0, lock=1) at cli.c:2295
ASTERISK-13 0x080c043f in ast_cli_generator (text=0x8f54c90 "console active", word=0x8c10065 "", state=0) at cli.c:2309
ASTERISK-14 0xb399bf5d in cli_alias_passthrough (e=0x8f54c18, cmd=-3, a=0xbf2ced9c) at res_clialiases.c:106
[...]
with over then 20k of stack frames.


When I dont have any CLI aliases created, no segfault happens (since the CLI command doesnt exist).

Comments:By: Sergio González Martín (telecos82) 2009-05-04 18:51:05

The problem is with the definition of the alias 'console=console active' in template asterisk12 (if we comment this line the segfault doesn't occur). For instance, when we enter dial, which is an alias for 'console dial', it translates it and then treats console as an alias for 'console active' entering in an infinte loop because it seems that console alias prioritizes over console command.



By: Russell Bryant (russell) 2009-05-05 15:20:26

Very nice investigation work, telecos82!

By: Digium Subversion (svnbot) 2009-05-06 09:35:48

Repository: asterisk
Revision: 192700

U   trunk/res/res_clialiases.c

------------------------------------------------------------------------
r192700 | file | 2009-05-06 09:35:47 -0500 (Wed, 06 May 2009) | 5 lines

Fix an infinite loop with tab completion of CLI aliases that reference themselves.

(closes issue ASTERISK-14055)
Reported by: junky

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

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

By: Digium Subversion (svnbot) 2009-05-06 09:37:33

Repository: asterisk
Revision: 192701

_U  branches/1.6.2/
U   branches/1.6.2/res/res_clialiases.c

------------------------------------------------------------------------
r192701 | file | 2009-05-06 09:37:32 -0500 (Wed, 06 May 2009) | 12 lines

Merged revisions 192700 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

........
 r192700 | file | 2009-05-06 11:35:47 -0300 (Wed, 06 May 2009) | 5 lines
 
 Fix an infinite loop with tab completion of CLI aliases that reference themselves.
 
 (closes issue ASTERISK-14055)
 Reported by: junky
........

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

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