[Home]

Summary:ASTERISK-12578: [patch] AMI UpdateConfig -- When creating category, memory allocation failure in config.c
Reporter:trevo (trevo)Labels:
Date Opened:2008-08-14 02:00:56Date Closed:2008-12-04 23:41:38.000-0600
Priority:CriticalRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) 20081113__bug13301__1.6.0.diff.txt
( 1) 20081113__bug13301.diff.txt
( 2) iax.conf
Description:Follow this telnet log to reproduce.  When attempting to execute the second block asterisk crashes and in the logs I see this error:
ERROR[28453] /builddir/build/BUILD/asterisk-1.6.0-beta9/include/asterisk/utils.h: Memory Allocation Failure in function ALLOC_COMMENT at line 129 of config.c


Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
Asterisk Call Manager/1.1
Action: login
Username: admin
Secret: admin
Events: off

Response: Success
Message: Authentication accepted

Action: UpdateConfig
SrcFilename: iax.conf
DstFilename: iax.tmp.conf
Reload: no
Action-000000: NewCat
Cat-000000: tmpcat

Connection closed by foreign host.
^ At this point asterisk dies
Comments:By: snuffy (snuffy) 2008-08-14 02:07:21

Does asterisk crash?
If so can you please follow the steps in doc/backtrace.txt and post a backtrace.

By: trevo (trevo) 2008-08-14 02:20:24

Asterisk dies every time I try those sequence of steps in telnet.

I followed the steps in backtrace.txt but no core file was produced so it's not a crash--asterisk is just exiting because of that mem alloc error.

By: Michiel van Baak (mvanbaak) 2008-08-14 12:26:06

Did you start asterisk with the -g flag ?

By: trevo (trevo) 2008-08-14 12:44:28

yes, I followed the steps in that txt

By: Michiel van Baak (mvanbaak) 2008-08-14 13:20:59

Can you upload your iax.conf file ?
Make sure to only obfuscate the ip addresses and passwords, but leave all other lines intact.

Cant reproduce it here with my iax.conf or the sample iax.conf

By: trevo (trevo) 2008-08-14 13:35:42

This is the standard iax.conf with just one new context at the end.

I had to rebuild this conf because my iax.conf had grown to 270mb!  I think is related to the bug I described.  NB: I only used iax.conf as my SrcFilename, never Dst.

By: trevo (trevo) 2008-08-14 14:27:28

This seems to be a larger problem or I'm not clear on AMI usage.  I have tried using the web interface to accomplish this and am running into the same problem (iax.conf grows at every iteration).

Here's what I'm doing:
http://localhost:8088/asterisk/rawman?action=login&username=foo&secret=bar

and then:
http://localhost:8088/asterisk/rawman?action=updateconfig&reload=no&srcfilename=iax.conf&dstfilename=iax.tmp.conf&Action-000000=newcat&Cat-000000=asdf&Var-000000=&Value-000000=

(following the formula given in the O'Reilly text)

Notice srcfilename is iax.conf and dstfilename is iax.tmp.conf
I attempt to create a new category 'asdf'.  Every time I run this process iax.conf increases in size by ~ a factor of 2--the contents of iax.conf are being appended to itself every time.  iax.tmp.conf, on the other hand, only contains [asdf]

This might explain the mem alloc problem--when the conf gets too large it can't be buffered.



By: snuffy (snuffy) 2008-08-14 16:47:31

hmm if you just want to add to current file why not use the 'append or insert' instead of newcat?

By: trevo (trevo) 2008-08-14 16:49:57

Can you append a new category?  I thought append just appended new variables to a category of interest.  I don't see any mention of insert in the docs.

By: snuffy (snuffy) 2008-08-14 18:22:05

i think i read the doc wrong.. nevermind.. ;)
but yes it does seem completely plausable that it runs out of memory if your iax.conf is as you say 270mb and your trying to add new category.. will have to look over code more closely

By: trevo (trevo) 2008-08-14 18:25:39

yeah I'm not surprised there's a mem alloc issue--the fact that you can double a conf's size by doing the above steps is troubling though.  I think it could be that Src and Dst are reversed in the code.



By: trevo (trevo) 2008-08-14 21:57:09

NB: I am not encountering this issue with asterisk 1.4*, only asterisk-1.6.0-beta9

By: snuffy (snuffy) 2008-08-15 16:57:44

Ok just to confirm then.
When you use 'newcat' on 1.6 beta 9 it is recreating the whole iax.conf file inside itself? (making two copies)
On 1.4 it does not?

By: Michiel van Baak (mvanbaak) 2008-08-17 14:49:58

Yes.
iax.conf will contain two copies of the content, and the iax.tmp.conf will only have:
[newcat]

I just tried it on trunk.

By: Tilghman Lesher (tilghman) 2008-11-13 23:43:57.000-0600

Fixed.  Patch uploaded (original patch is for trunk and 1.6.1, second patch is for 1.6.0 only).  This is a regression, so it will be fixed in 1.6.0.

Please test and verify this fix.

By: Leif Madsen (lmadsen) 2008-11-24 16:00:29.000-0600

Confirmed this issue by reproducing it. Patch resolves the issue for me (I used the one without '1.6.0' in the name)

By: Jason Parker (jparker) 2008-12-04 17:27:24.000-0600

Corydon76, check out S_COR() in trunk/1.6

By: Digium Subversion (svnbot) 2008-12-04 23:41:37.000-0600

Repository: asterisk
Revision: 161181

U   trunk/main/config.c

------------------------------------------------------------------------
r161181 | tilghman | 2008-12-04 23:41:36 -0600 (Thu, 04 Dec 2008) | 11 lines

The first file should have a blank config filename in the structure, so that
when a save occurs to a different filename, everything goes to the alternate
filename, instead of appending to the original.  This is important for the
AMI command UpdateConfig.
(closes issue ASTERISK-12578)
Reported by: trevo
Patches:
      20081113__bug13301.diff.txt uploaded by Corydon76 (license 14)
      20081113__bug13301__1.6.0.diff.txt uploaded by Corydon76 (license 14)
Tested by: Corydon76, blitzrage

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

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