Summary:ASTERISK-02590: tab completion on show dialplan from -r asterisk with large extensions.conf will segfault
Reporter:Brian West (bkw918)Labels:
Date Opened:2004-10-12 17:31:53Date Closed:2008-01-15 15:10:30.000-0600
Versions:Frequency of
Environment:Attachments:( 0) asterisk-climatches.patch.txt
( 1) bt.txt
( 2) mydiff.txt
Description:If you have a extensions.conf with 18k lines and about 800 contexts and you press "show dialplan <tab>" your -r will lock up and asterisk will segfault when you press ctrl+c to exit the locked up -r session.  This however doesn't happen when you do it from the -c console.  
Comments:By: Tilghman Lesher (tilghman) 2004-10-12 23:17:40

Any idea on the process memory usage when this occurs?  Seems like you might have run into the maximum process memory limit.

By: James Golovich (jamesgolovich) 2004-10-13 22:20:51

Heres a patch that should take care of it, and provide a tiny bit of optimization since it doesn't strlen the string twice.

Let me know if it works for you

By: Tilghman Lesher (tilghman) 2004-10-13 22:36:20

Just a thought, but shouldn't we be checking the return value of realloc?  According to the manpage, it can return NULL if it fails, and the current code would leave a section of memory allocated with no remaining handle (big memory leak if realloc fails).

By: James Golovich (jamesgolovich) 2004-10-13 22:49:54

Yeah it is always good to check for NULL especially with memory management stuff.  It's pretty unlikely to happen unless all memory is exhausted which is a very rare thing to happen nowadays, but it can happen.

The way the code works now, to do anything really useful in regards to dealing with the memory leak will need us to keep an old pointer around.  I'm not sure if its even worth worrying about freeing the memory, just detecting the failure so we don't try to use buf it its NULL.

By: Brian West (bkw918) 2004-10-13 22:56:23

Seems to fix it. :)

By: Tilghman Lesher (tilghman) 2004-10-13 23:23:27

It wouldn't necessarily mean that you've exhausted memory -- only that memory is fragmented enough that a block of memory of the requested size is not currently available.  Smaller bits of memory are likely to be still available in this case.

By: Mark Spencer (markster) 2004-10-14 00:11:40

Fixed in CVS head, thanks!

By: Russell Bryant (russell) 2004-10-14 18:51:01

fixed in the 1.0 branch

By: Digium Subversion (svnbot) 2008-01-15 15:10:19.000-0600

Repository: asterisk
Revision: 3994

U   trunk/cli.c

r3994 | markster | 2008-01-15 15:10:18 -0600 (Tue, 15 Jan 2008) | 2 lines

Handle excessive entries properly (bug ASTERISK-2590)



By: Digium Subversion (svnbot) 2008-01-15 15:10:30.000-0600

Repository: asterisk
Revision: 4008

U   branches/v1-0/cli.c

r4008 | russell | 2008-01-15 15:10:30 -0600 (Tue, 15 Jan 2008) | 2 lines

tab completion on show dialplan from -r asterisk with large extensions.conf will segfault (bug ASTERISK-2590)