[Home]

Summary:ASTERISK-16213: [patch] parser mangles #include
Reporter:Sean Darcy (seandarcy)Labels:
Date Opened:2010-06-05 10:10:49Date Closed:2010-07-06 15:05:48
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) 20100613__issue17472.diff.txt
( 1) 20100628__issue17472.diff.txt
( 2) config.patch
( 3) config2.patch
Description:With an #include in extensions.conf:

[general]
static=yes
writeprotect=no

#include "exts/extensions-for-fax"

[globals]
TRUNK=DAHDI/g0
TRUNKMSD=1
.............

to a file that exists:

ls -l exts/extensions-for-fax
-rw-r--r--. 1 root root 6157 Nov 13  2009 exts/extensions-for-fax

the parser mangles the #include:

== Parsing '/etc/asterisk/extensions.conf':   == Found
[Jun  5 10:41:42] ERROR[26393]: config.c:1098 process_text_line: The file 'exts/etensions--for-fax' was listed as a #include but it does not exist.


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

The parser appears to be dropping the 7th character and doubling the 16th character:

#include  "1234567890extensions-for-fax"

generates:

 == Parsing '/etc/asterisk/extensions.conf':   == Found
[Jun  5 11:08:05] ERROR[26491]: config.c:1098 process_text_line: The file '123456890extenssions-for-fax' was listed as a #include but it does not exist.

Comments:By: Sean Darcy (seandarcy) 2010-06-05 14:06:16

After messing around some more, I found that not using quotes solves this.

That is

#include exts/myfile

works.

#include "exts/myfile"

does not work.

I'm pretty sure this is a regression from 1.6.2.7, since this is the same extensions.conf file. But WFM now!

By: Tilghman Lesher (tilghman) 2010-06-05 23:42:15

I am unable to reproduce this in 1.6.2.8, 1.6.2 SVN, or trunk.  Are you perhaps running some patches of your own, other than pure 1.6.2.8?  Even something seemingly innocuous could be causing this.

[Jun  5 23:25:47] ERROR[29090]: config.c:1098 process_text_line: The file '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ' was listed as a #include but it does not exist.
[Jun  5 23:25:47] ERROR[29090]: app_voicemail.c:10681 load_config: Config file voicemail.conf is in an invalid format.  Aborting.

By: Sean Darcy (seandarcy) 2010-06-06 19:00:25

Nope. Plain vanilla 1.6.2.8.

I tried using single quotes - is that what you did? - and got the same:


ERROR[3317]: config.c:1098 process_text_line: The file ''exts/extensions-for-fax'' was listed as a #include but it does not exist.

It's not mangled, but the file does exist. Without the single quotes it works.

With double quotes I still get the original error:

ERROR[3326]: config.c:1098 process_text_line: The file 'exts/exensions--for-fax' was listed as a #include but it does not exist.

So could you try to reproduce with single and double quotes on a real file?

By: Tilghman Lesher (tilghman) 2010-06-06 22:30:16

Nope, double quotes, same as you.  Single quotes are not supported, only double quotes and less-than and greater-than signs.

By: Tilghman Lesher (tilghman) 2010-06-06 22:51:54

Once with the file not existing; once with it existing, as expected, not mangled.

*CLI> module reload app_voicemail.so
   -- Reloading module 'app_voicemail.so' (Comedian Mail (Voicemail System))
 == Parsing '/etc/asterisk/voicemail.conf':   == Found
[Jun  6 22:49:15] ERROR[29090]: config.c:1098 process_text_line: The file '01234567890qwertyuiopasdfghjklzxcvbnm' was listed as a #include but it does not exist.
[Jun  6 22:49:15] ERROR[29090]: app_voicemail.c:10675 load_config: Config file voicemail.conf is in an invalid format.  Aborting.
*CLI> module reload app_voicemail.so
   -- Reloading module 'app_voicemail.so' (Comedian Mail (Voicemail System))
 == Parsing '/etc/asterisk/voicemail.conf':   == Found
 == Parsing '/etc/asterisk/01234567890qwertyuiopasdfghjklzxcvbnm':   == Found
*CLI> core show version
Asterisk 1.6.2.8 built by tilghman @ gadolinium.jeffandtilghman.foo on a i686 running Linux on 2010-06-06 04:29:21 UTC

By: Sean Darcy (seandarcy) 2010-06-07 05:10:08

Puzzled:

#include <exts/extensions-for-fax>
 == Parsing '/etc/asterisk/exts/extensions-for-fax':   == Found

#include "exts/extensions-for-fax"
ERROR[3829]: config.c:1098 process_text_line: The file 'exts/exensions--for-fax' was listed as a #include but it does not exist.

core show version
Asterisk 1.6.2.8 built by asterisk @ PBX on a x86_64 running Linux

But on another x86_64 machine (but AMD gcc-4.4.3, Fedora 12, rather than Intel gcc version 4.4.4, Fedora 13) the double quotes worked for me also.

By: Tilghman Lesher (tilghman) 2010-06-07 10:37:53

I think we need you to figure out just exactly what it is about that setup that causes the problem.  Without the ability to reproduce the problem, it's difficult for us to track down the issue.

By: Sean Darcy (seandarcy) 2010-06-07 16:01:08

I agree. Planning on upgrading the F12 machine (where double quotes work) to F13 (where they don't) this weekend. So we'll see if gcc-4.4.4 is our culprit.

By: Leif Madsen (lmadsen) 2010-06-09 10:31:44

Setting to feedback until after the upgrade on the machine in question :)

By: Daniel Lynes (dlynes) 2010-06-11 07:27:34

Same thing happens to me on:  Asterisk 1.6.2.5-0ubuntu1 built by buildd @ yellow on a x86_64 running Linux on 2010-04-16 05:34:19 UTC

[Jun 11 05:17:21]   == Parsing '/etc/asterisk/extensions.conf': [Jun 11 05:17:21]   == Found
The file 'macro.cconf' was listed as a #include but it does not exist.

In my extensions.conf file, this happens when I include using double quotation marks, but not when I include using angle brackets. (#include "macros.conf" vs #include <macros.conf>).

If it also helps, Ubuntu 10.04 ships with gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3, so that's probably the version that it's compiled with.  But, if that's the issue, I would think it's probably more a memory corruption issue or something that comes out in the wash when certain optimizations are enabled in gcc 4.4.3.

modules.conf:
;
; Asterisk configuration file
;
; Module Loader configuration file
;

[modules]
autoload=yes
;
; Any modules that need to be loaded before the Asterisk core has been
; initialized (just after the logger has been initialized) can be loaded
; using 'preload'. This will frequently be needed if you wish to map all
; module configuration files into Realtime storage, since the Realtime
; driver will need to be loaded before the modules using those configuration
; files are initialized.
;
; An example of loading ODBC support would be:
;preload => res_odbc.so
;preload => res_config_odbc.so
;
; If you want, load the GTK console right away.  
; Don't load the KDE console since
; it's not as sophisticated right now.
;
;noload => res_ael_share.so
;noload => pbx_ael.so
load => pbx_config.so
noload => pbx_lua.so
noload => pbx_gtkconsole.so
;load => pbx_gtkconsole.so
noload => pbx_kdeconsole.so
;
; Intercom application is obsoleted by
; chan_oss.  Don't load it.
;
noload => app_intercom.so
;
; The 'modem' channel driver and its subdrivers are
; obsolete, don't load them.
;
noload => chan_modem.so
noload => chan_modem_aopen.so
noload => chan_modem_bestdata.so
noload => chan_modem_i4l.so
noload => chan_jabber.so

;
; Comment this out (after installing CAPI middleware and hardware
; drivers) if you have CAPI-able hardware and wish to use it in
; Asterisk.
;
noload => chan_capi.so
;
load => res_musiconhold.so
;
; Load either OSS or ALSA, not both
; By default, load OSS only (automatically) and do not load ALSA
;
noload => chan_alsa.so
;noload => chan_oss.so
;
; Disable CDR logging to SQLite by default since it writes unconditionally to
; cdr.db without a way to rotate it.
;
noload => cdr_sqlite.so
;
; These conflict with app_voicemail.so/app_directory.so and each other
; These are for IMAP and ODBC storage for Voicemail
noload => app_directory_odbc.so
noload => app_voicemail_odbc.so
noload => app_voicemail_imap.so
;
; Enable these if you want to configure Asterisk in a database
;
noload => res_config_odbc.so
noload => res_config_pgsql.so
;
; Module names listed in "global" section will have symbols globally
; exported to modules loaded after them.
;
[global]

By: Tilghman Lesher (tilghman) 2010-06-11 12:42:39

dlynes:  You touched on gcc optimizations.  Does the problem disappear if you compile Asterisk with the DONT_OPTIMIZE flag?

By: Sean Darcy (seandarcy) 2010-06-12 13:00:54

I upgraded another machine to Fedora 13, gcc-4.4.4. Rebuilt asterisk.

No problem with using double quotes. Really stumped.

Both my machines do NOT have the DONT_OPTIMIZE flag.

By: Nico van der Walt (nivan) 2010-06-13 11:30:18

I'm experiencing the same problem with Asterisk 1.6.2.8 running on Ubuntu 10.04 server (64bit). Tried with DONT_OPTIMIZE flag with same error.

module load pbx_config.so gives the following error:

config.c:1098 process_text_line: The file 'dialpla/extensiions.conf' was listed as a #include but it does not exist.

I have the following line in extensions.conf:

#include "dialplan/extensions.conf"

The directory exists.

By: Nico van der Walt (nivan) 2010-06-13 12:40:38

When reverting to the previous code to strip out the quotes everything works. Maybe the 'strcpy(c, c + 1)' does not play nice with gcc 4.4.3? Here is the diff for main/config.c:

<removed inline patch>



By: Tilghman Lesher (tilghman) 2010-06-13 13:19:42

Well, if it's the strcpy() at fault, then changing it to ast_copy_string should work fine, right?

By: Daniel Lynes (dlynes) 2010-06-13 20:20:02

I've noticed changing it to do '#include <filename>', instead of '#include "filename"' fixes the problem.  So, it just seems to be a problem when using double quote marks.

By: Nico van der Walt (nivan) 2010-06-21 11:43:54

Uploaded a patch that combines the logic for ", ' and <> quotes. Tested it with all three forms of quotes and found it working. Can anyone else test?

By: Tilghman Lesher (tilghman) 2010-06-21 15:11:24

I'm fine with this change, other than making the single quote into a recognized quote character.  Strip that one out.

By: Nico van der Walt (nivan) 2010-06-21 16:34:39

Uploaded new patch (config2.patch) to prevent parser from recognizing single quote as quote character. Thanks tilghman.

By: Digium Subversion (svnbot) 2010-06-28 16:29:24

Repository: asterisk
Revision: 272921

U   branches/1.4/main/config.c

------------------------------------------------------------------------
r272921 | tilghman | 2010-06-28 16:29:24 -0500 (Mon, 28 Jun 2010) | 8 lines

Change the way that we read include files, to accommodate for changes in GCC 4.4.

(closes issue ASTERISK-16213)
Reported by: seandarcy
Patches:
      config2.patch uploaded by nivan (license 1066)
Tested by: nivan

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

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

By: Digium Subversion (svnbot) 2010-06-28 16:42:49

Repository: asterisk
Revision: 272923

_U  trunk/
U   trunk/main/config.c

------------------------------------------------------------------------
r272923 | tilghman | 2010-06-28 16:42:49 -0500 (Mon, 28 Jun 2010) | 19 lines

Merged revisions 272921-272922 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
 r272921 | tilghman | 2010-06-28 16:29:27 -0500 (Mon, 28 Jun 2010) | 8 lines
 
 Change the way that we read include files, to accommodate for changes in GCC 4.4.
 
 (closes issue ASTERISK-16213)
  Reported by: seandarcy
  Patches:
        config2.patch uploaded by nivan (license 1066)
  Tested by: nivan
........
 r272922 | tilghman | 2010-06-28 16:38:49 -0500 (Mon, 28 Jun 2010) | 2 lines
 
 Also trim trailing blanks on #includes
........

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

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

By: Digium Subversion (svnbot) 2010-06-28 16:46:42

Repository: asterisk
Revision: 272924

_U  branches/1.6.2/
U   branches/1.6.2/main/config.c

------------------------------------------------------------------------
r272924 | tilghman | 2010-06-28 16:46:42 -0500 (Mon, 28 Jun 2010) | 26 lines

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

................
 r272923 | tilghman | 2010-06-28 16:42:52 -0500 (Mon, 28 Jun 2010) | 19 lines
 
 Merged revisions 272921-272922 via svnmerge from
 https://origsvn.digium.com/svn/asterisk/branches/1.4
 
 ........
   r272921 | tilghman | 2010-06-28 16:29:27 -0500 (Mon, 28 Jun 2010) | 8 lines
   
   Change the way that we read include files, to accommodate for changes in GCC 4.4.
   
   (closes issue ASTERISK-16213)
    Reported by: seandarcy
    Patches:
          config2.patch uploaded by nivan (license 1066)
    Tested by: nivan
 ........
   r272922 | tilghman | 2010-06-28 16:38:49 -0500 (Mon, 28 Jun 2010) | 2 lines
   
   Also trim trailing blanks on #includes
 ........
................

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

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