Summary:ASTERISK-05362: Adding #include directory causes Asterisk to deadlock (and in the case of Debian Sarge the entire machine)
Reporter:jamie (jamie)Labels:
Date Opened:2005-10-25 02:20:40Date Closed:2008-01-15 15:52:54.000-0600
Versions:Frequency of
Environment:Attachments:( 0) config.c.patch
Description:These are the steps to reproduce:

cd /etc/asterisk
mkdir extensions
echo "#include extensions" >> extensions.conf

Then reload asterisk.

It appears to hang, but since it causes each computer I've test it on to hang completely, I can't run top or otherwise figure out what is happening.
Comments:By: Olle Johansson (oej) 2005-10-25 02:30:21

Whas there any file in the extensions directory?

By: Olle Johansson (oej) 2005-10-25 02:32:23

With an empty directory (like your example) nothing really happens on FreeBSD. I get a short dial plan with the parkedcalls context. Asterisk is happily running.

By: Mark Spencer (markster) 2005-10-25 12:36:07

I cannot duplicate this on my system on CVS head on my fedora linux system.  Are you running with the -p flag, perchance?

By: Olle Johansson (oej) 2005-10-25 14:54:13

Can not repeat on my fedora either.

By: jamie (jamie) 2005-10-26 00:01:18

Ok - Now I've tested with CVS HEAD and get similar if less catastrophic results. I'm not a programmer - so please send detailed instructions on how to run more useful tests.

This is what I'm running and what I've done:

Running Dell Inspiron 700M (512M RAM,Pentium 4)
Debian Etch - fully updated

Via CVS, checked just asterisk and libpri (I guess I didn't need libpri...).
cd librpi, make clean, make install
cd asterisk, make clean, make install, make samples, make mpg123


sudo /usr/sbin/asterisk
sudo /usr/sbin/asterisk -vvvvvcr
[From console]: reload
Works fine - see Asterisk reporting on parsing all the files

Then from another terminal:
cd /etc/asterisk
mkdir extensions
[edit /etc/extensions.conf and add at the end of the file]
#include extensions

(I tried both with the directory empty and with a file with just a comment in the directory - same result).

Then - from the asterisk console I typed reload
Asterisk responds with a carraige return, but nothing else (unlike the first time I typed reload, when it displays the files being parsed).

My machine doesn't lockup, but asterisk takes up 98 - 99% of %CPU in top.

p.s. The systems in which this problem crashed the entire machine *were* running with -p. However - in my latest test described above I'm not passing any arguments to asterisk.

p.s.s. perhaps this bug should be posted to the debian maintainer?

By: jamie (jamie) 2005-10-30 19:54:20.000-0600


For people who could not duplicate - did you check to see if asterisk was consuming 99% of system resources (if running without -p on my systems, it doesn't crash, instead simply consumes massive resources)?

More info:

I ran /usr/sbin/asterisk


strace -p `cat /var/run/asterisk.pid` 2> asterisk.dump

I let it run for about 30 seconds then killed the process.

The asterisk.dump file had the line:

read(18, 0xb7ae2000, 4096)              = -1 EISDIR (Is a directory)

about 950449 times.

By: jamie (jamie) 2005-10-31 15:35:30.000-0600

I just attached a patch that works for me.

I'm not much of a C programmer (this patch constitutes the only C programing code I've ever written). But - it compiles and when I try to include a directory, rather than causing Asterisk to hang, it gives a reasonable error about not being able to include a directory.

On a deeper level - I'm not sure why fopen returns false when trying to open a file that does not exist - yet creates a loop when there's a directory. Maybe there are other cases that will cause a loop as well? This patch only tests for a directory.

Anyway - I hope this patch is useful. Thanks for all the amazing work you've done on Asterisk!

By: Tzafrir Cohen (tzafrir) 2005-10-31 16:08:24.000-0600

See ASTERISK-4517 , though this patch is probably slightly better than the patch there.
(and yes, the patch there *is* disclaimed)

By: Kevin P. Fleming (kpfleming) 2005-10-31 16:18:43.000-0600

Fixed in CVS HEAD, although I used a different fix that also ignores all other types of non-regular files. Thanks!

By: Digium Subversion (svnbot) 2008-01-15 15:52:54.000-0600

Repository: asterisk
Revision: 6902

U   trunk/config.c

r6902 | kpfleming | 2008-01-15 15:52:54 -0600 (Tue, 15 Jan 2008) | 2 lines

ignore non-regular files during config parsing (issue ASTERISK-5362, different fix)