[Home]

Summary:ASTERISK-04980: [patch] Asterisk crashes when macro recurses infinitely
Reporter:David James (davidj)Labels:
Date Opened:2005-09-04 19:29:55Date Closed:2008-01-15 15:47:23.000-0600
Priority:CriticalRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) 20050906__bug5114__try2.diff.txt
Description:[macro-break]
exten => 1,s,Macro(break)

[default]
exten => 666,1,Macro(break)



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

Thread 1 (process 32102):
#0  0x08089f42 in pbx_extension_helper (c=0xa0de8c8, con=0x0, context=0x3089d70 "macro-break", exten=0xa9d2f0 "s", priority=1,
   label=0x0, callerid=0xa0b0390 "354", action=0) at pbx.c:1562
#1  0x0808bb5d in ast_exists_extension (c=0xa0de8c8, context=0x3089d70 "macro-break", exten=0xa9d2f0 "s", priority=1,
   callerid=0xa0b0390 "354") at pbx.c:2145
#2  0x00a9b355 in macro_exec (chan=0xa0de8c8, data=0x308e000) at app_macro.c:116
#3  0x08086df2 in pbx_exec (c=0xa0de8c8, app=0xa068e08, data=0x308e000, newstack=1) at pbx.c:553
#4  0x0808a51c in pbx_extension_helper (c=0xa0de8c8, con=0x0, context=0xa0dea2c "macro-break", exten=0xa0deb20 "s", priority=1,
   label=0x0, callerid=0xa0b0390 "354", action=1) at pbx.c:1637
ASTERISK-1  0x0808bcd9 in ast_spawn_extension (c=0xa0de8c8, context=0xa0dea2c "macro-break", exten=0xa0deb20 "s", priority=1,
   callerid=0xa0b0390 "354") at pbx.c:2170
ASTERISK-2  0x00a9b9f4 in macro_exec (chan=0xa0de8c8, data=0x30948d0) at app_macro.c:177
ASTERISK-3  0x08086df2 in pbx_exec (c=0xa0de8c8, app=0xa068e08, data=0x30948d0, newstack=1) at pbx.c:553
ASTERISK-4  0x0808a51c in pbx_extension_helper (c=0xa0de8c8, con=0x0, context=0xa0dea2c "macro-break", exten=0xa0deb20 "s", priority=1,
   label=0x0, callerid=0xa0b0390 "354", action=1) at pbx.c:1637
ASTERISK-5  0x0808bcd9 in ast_spawn_extension (c=0xa0de8c8, context=0xa0dea2c "macro-break", exten=0xa0deb20 "s", priority=1,
   callerid=0xa0b0390 "354") at pbx.c:2170
ASTERISK-6 0x00a9b9f4 in macro_exec (chan=0xa0de8c8, data=0x309b1a0) at app_macro.c:177
---Type <return> to continue, or q <return> to quit---
ASTERISK-7 0x08086df2 in pbx_exec (c=0xa0de8c8, app=0xa068e08, data=0x309b1a0, newstack=1) at pbx.c:553
ASTERISK-8 0x0808a51c in pbx_extension_helper (c=0xa0de8c8, con=0x0, context=0xa0dea2c "macro-break", exten=0xa0deb20 "s", priority=1,
   label=0x0, callerid=0xa0b0390 "354", action=1) at pbx.c:1637
ASTERISK-9 0x0808bcd9 in ast_spawn_extension (c=0xa0de8c8, context=0xa0dea2c "macro-break", exten=0xa0deb20 "s", priority=1,
   callerid=0xa0b0390 "354") at pbx.c:2170
ASTERISK-10 0x00a9b9f4 in macro_exec (chan=0xa0de8c8, data=0x30a1a70) at app_macro.c:177
ASTERISK-11 0x08086df2 in pbx_exec (c=0xa0de8c8, app=0xa068e08, data=0x30a1a70, newstack=1) at pbx.c:553
ASTERISK-12 0x0808a51c in pbx_extension_helper (c=0xa0de8c8, con=0x0, context=0xa0dea2c "macro-break", exten=0xa0deb20 "s", priority=1,
   label=0x0, callerid=0xa0b0390 "354", action=1) at pbx.c:1637
ASTERISK-13 0x0808bcd9 in ast_spawn_extension (c=0xa0de8c8, context=0xa0dea2c "macro-break", exten=0xa0deb20 "s", priority=1,
   callerid=0xa0b0390 "354") at pbx.c:2170
ASTERISK-14 0x00a9b9f4 in macro_exec (chan=0xa0de8c8, data=0x30a8340) at app_macro.c:177
ASTERISK-15 0x08086df2 in pbx_exec (c=0xa0de8c8, app=0xa068e08, data=0x30a8340, newstack=1) at pbx.c:553
ASTERISK-16 0x0808a51c in pbx_extension_helper (c=0xa0de8c8, con=0x0, context=0xa0dea2c "macro-break", exten=0xa0deb20 "s", priority=1,
   label=0x0, callerid=0xa0b0390 "354", action=1) at pbx.c:1637
ASTERISK-17 0x0808bcd9 in ast_spawn_extension (c=0xa0de8c8, context=0xa0dea2c "macro-break", exten=0xa0deb20 "s", priority=1,
   callerid=0xa0b0390 "354") at pbx.c:2170
ASTERISK-18 0x00a9b9f4 in macro_exec (chan=0xa0de8c8, data=0x30aec10) at app_macro.c:177
ASTERISK-19 0x08086df2 in pbx_exec (c=0xa0de8c8, app=0xa068e08, data=0x30aec10, newstack=1) at pbx.c:553
ASTERISK-20 0x0808a51c in pbx_extension_helper (c=0xa0de8c8, con=0x0, context=0xa0dea2c "macro-break", exten=0xa0deb20 "s", priority=1,
   label=0x0, callerid=0xa0b0390 "354", action=1) at pbx.c:1637
ASTERISK-21 0x0808bcd9 in ast_spawn_extension (c=0xa0de8c8, context=0xa0dea2c "macro-break", exten=0xa0deb20 "s", priority=1,
   callerid=0xa0b0390 "354") at pbx.c:2170
ASTERISK-22 0x00a9b9f4 in macro_exec (chan=0xa0de8c8, data=0x30b54e0) at app_macro.c:177
ASTERISK-23 0x08086df2 in pbx_exec (c=0xa0de8c8, app=0xa068e08, data=0x30b54e0, newstack=1) at pbx.c:553
ASTERISK-24 0x0808a51c in pbx_extension_helper (c=0xa0de8c8, con=0x0, context=0xa0dea2c "macro-break", exten=0xa0deb20 "s", priority=1,
   label=0x0, callerid=0xa0b0390 "354", action=1) at pbx.c:1637
ASTERISK-25 0x0808bcd9 in ast_spawn_extension (c=0xa0de8c8, context=0xa0dea2c "macro-break", exten=0xa0deb20 "s", priority=1,
   callerid=0xa0b0390 "354") at pbx.c:2170
ASTERISK-26 0x00a9b9f4 in macro_exec (chan=0xa0de8c8, data=0x30bbdb0) at app_macro.c:177
ASTERISK-27 0x08086df2 in pbx_exec (c=0xa0de8c8, app=0xa068e08, data=0x30bbdb0, newstack=1) at pbx.c:553
ASTERISK-28 0x0808a51c in pbx_extension_helper (c=0xa0de8c8, con=0x0, context=0xa0dea2c "macro-break", exten=0xa0deb20 "s", priority=1,
   label=0x0, callerid=0xa0b0390 "354", action=1) at pbx.c:1637
ASTERISK-29 0x0808bcd9 in ast_spawn_extension (c=0xa0de8c8, context=0xa0dea2c "macro-break", exten=0xa0deb20 "s", priority=1,
   callerid=0xa0b0390 "354") at pbx.c:2170
ASTERISK-30 0x00a9b9f4 in macro_exec (chan=0xa0de8c8, data=0x30c2680) at app_macro.c:177
ASTERISK-31 0x08086df2 in pbx_exec (c=0xa0de8c8, app=0xa068e08, data=0x30c2680, newstack=1) at pbx.c:553
ASTERISK-32 0x0808a51c in pbx_extension_helper (c=0xa0de8c8, con=0x0, context=0xa0dea2c "macro-break", exten=0xa0deb20 "s", priority=1,
   label=0x0, callerid=0xa0b0390 "354", action=1) at pbx.c:1637
ASTERISK-33 0x0808bcd9 in ast_spawn_extension (c=0xa0de8c8, context=0xa0dea2c "macro-break", exten=0xa0deb20 "s", priority=1,
   callerid=0xa0b0390 "354") at pbx.c:2170
ASTERISK-34 0x0808c196 in __ast_pbx_run (c=0xa0de8c8) at pbx.c:2236
ASTERISK-35 0x0808cf39 in ast_pbx_run (c=0xa0de8c8) at pbx.c:2457
ASTERISK-36 0x0808cd78 in pbx_thread (data=0xa0de8c8) at pbx.c:2419
ASTERISK-37 0x0075bde8 in start_thread () from /lib/tls/libpthread.so.0
ASTERISK-38 0x00dd593a in clone () from /lib/tls/libc.so.6
Comments:By: Tilghman Lesher (tilghman) 2005-09-05 01:38:36

You created an infinite loop and it ran out of memory.  While technically a condition (running out of memory) we should prevent, creating an infinite loop is not something that we should prevent.



By: Tilghman Lesher (tilghman) 2005-09-05 02:06:06

Given that line 1562 is where you ended up, you simply ran out of stack space.  I don't think there's really much of anything we can do to catch this; this isn't a programming error.

By: David James (davidj) 2005-09-05 03:29:57

Corydon76 -- this is a critical issue, please advise further action towards closure.

By: Michael Jerris (mikej) 2005-09-05 08:09:01

He's advising to not create a macro that calls itself.

By: Brian West (bkw918) 2005-09-05 13:36:28

This is a bug no matter how you put it.  It needs to be fixed.

/b

By: Brian West (bkw918) 2005-09-05 13:37:46

On that thought macros should only go so many levels deep like includes.

/b

By: Tilghman Lesher (tilghman) 2005-09-05 15:54:16

Patch added implementing loop detection.  Needs testing.  DoF.

By: Brian West (bkw918) 2005-09-05 16:11:03

this will limit you to running a total of 7 macros in a row before it stops working?

/b

By: Tilghman Lesher (tilghman) 2005-09-05 16:16:52

That's correct.  The trace given in this bugset shows that Asterisk will only tolerate 42 stack frames, 4 each for each Macro recursion.  That's a maximum of 10 recursive Macros, but we should leave some breathing room for other applications to execute.

By: Brian West (bkw918) 2005-09-05 19:42:19

I was speaking in terms of:

exten => 1,1,Macro(test1)
exten => 1,1,Macro(test2)
exten => 1,1,Macro(test3)
exten => 1,1,Macro(test4)
exten => 1,1,Macro(test5)
exten => 1,1,Macro(test6)
exten => 1,1,Macro(test7)
exten => 1,1,Macro(test8)

This would also fail.
/b

By: Tilghman Lesher (tilghman) 2005-09-05 20:09:15

Hopefully incrementing priorities, but I get your drift.  ;-)

Replacement patch uploaded.

By: Brian West (bkw918) 2005-09-05 22:05:18

Doh! ;)

By: Tilghman Lesher (tilghman) 2005-09-06 12:40:46

Patch now tested.  I had to reduce the number of tolerable recursions by one, since on my system, that still caused an out of stack space memory error.

By: Kevin P. Fleming (kpfleming) 2005-09-07 16:37:06

You all understand, of course, that there are dozens of ways to crash Asterisk in a similar manner... :-)

By: Kevin P. Fleming (kpfleming) 2005-09-07 16:39:09

Committed to CVS HEAD, thanks!

By: Digium Subversion (svnbot) 2008-01-15 15:47:23.000-0600

Repository: asterisk
Revision: 6535

U   trunk/apps/app_macro.c

------------------------------------------------------------------------
r6535 | kpfleming | 2008-01-15 15:47:23 -0600 (Tue, 15 Jan 2008) | 2 lines

put a limit on Macro depth (to combat recursion) (issue ASTERISK-4980)

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

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