Summary:ASTERISK-19711: Crash emanating from add_exten_to_pattern_tree()
Reporter:Mark Murawski (kobaz)Labels:
Date Opened:2012-04-11 15:47:30Date Closed:2015-02-27 19:01:52.000-0600
Versions: Frequency of
duplicatesASTERISK-24444 PBX: Crash when generating extension for pattern matching hint
Environment:Attachments:( 0) backtrace-2014-10-10T09:07:59+0200.txt
( 1) backtrace-2014-10-10T09:12:00+0200.txt
( 2) backtrace-2014-10-10T09:16:00+0200.txt
( 3) backtrace-250412.txt
( 4) bt
( 5) bt-full
Description:Reproducibility is pretty random but it does happen often when doing lots of:

{{dialplan add extension xxx}} from the console

The crash will get triggered especially when the extension already exists.

Comments:By: Mark Murawski (kobaz) 2012-04-11 15:49:33.415-0500

Attached backtrace

By: Mark Murawski (kobaz) 2012-04-11 15:49:55.372-0500

Attached backtrace full

By: Mark Murawski (kobaz) 2012-04-11 15:51:27.069-0500

(gdb) up
#1  0xb7536150 in vsnprintf () from /lib/i686/cmov/libc.so.6
(gdb) up
#2  0x0817c2c8 in __ast_str_helper (buf=0xaf3dfab4, max_len=8192, append=0, fmt=0x81e19a4 "Found duplicate exten. Had %s found %s\n", ap=0xaf3dfb24 "handdpd\bPñ`·\001") at strings.c:72
72                      res = vsnprintf((*buf)->__AST_STR_STR + offset, (*buf)->__AST_STR_LEN - offset, fmt, aq);
(gdb) up
#3  0x0818cd8a in ast_str_set_va (buf=0xaf3dfab4, max_len=8192, fmt=0x81e19a4 "Found duplicate exten. Had %s found %s\n", ap=0xaf3dfb24 "handdpd\bPñ`·\001")
   at /usr/home/markm/asterisk/1.8.5-custom/include/asterisk/strings.h:776
776     AST_INLINE_API(int __attribute__((format(printf, 3, 0))) ast_str_set_va(struct ast_str **buf, ssize_t max_len, const char *fmt, va_list ap),
(gdb) up
#4  0x0811c16c in ast_log (level=3, file=0x81e0874 "pbx.c", line=2060, function=0x81e662b "add_exten_to_pattern_tree", fmt=0x81e19a4 "Found duplicate exten. Had %s found %s\n") at logger.c:1230
1230            res = ast_str_set_va(&buf, BUFSIZ, fmt, ap);
(gdb) up
#5  0x081364e4 in add_exten_to_pattern_tree (con=0x8644700, e1=0x8647028, findonly=1) at pbx.c:2060
2060                                            ast_log(LOG_WARNING, "Found duplicate exten. Had %s found %s\n", m2->exten->exten, e1->exten);
(gdb) p m2->exten->exten
$23 = 0x646e6168 <Address 0x646e6168 out of bounds>

By: Matt Jordan (mjordan) 2012-04-12 08:49:04.425-0500

You know, I swore we fixed this before.  Probably yet another way the duplicate extension stuff ends up with a just character pointer when we think it shouldn't.

By: Mark Murawski (kobaz) 2012-04-12 09:41:24.145-0500

What rev was there a fix for this?

By: Sébastien Couture (sysreq) 2012-04-25 08:36:49.248-0500

We've had the same issue several times over the last couple weeks, both on (this backtrace) and

In my case, it seems to be related to dynamic hints generation using a func_odbc function.

I've got the following in my dialplan:

exten => _X.,hint,${HINTS_GET(agi0001,${FILTER(0-9,${EXTEN})})}

Where ${HINTS_GET()} fetches a string of SIP devices delimited by &'s, which is valid for a hint.

The issue seems to be that in this case, a phone tried to subscribe to '418-766-2000 x4696' and _X. picked up on it, thus creating a hint for an extension that has spaces in it, and then subscribing to it multiple times.

[Apr 25 09:15:52] VERBOSE[22838] pbx.c: [Apr 25 09:15:52]     -- Added extension '418-766-2000x4696' priority -1 to agi0001
[Apr 25 09:15:52] WARNING[22838] pbx.c: Found duplicate exten. Had 418-766-2000x4696 found 418-766-2000x4696
[Apr 25 09:15:52] WARNING[22838] pbx.c: Unable to register extension '418-766-2000x4696', priority -1 in 'agi0001', already in use

By: alexr1 (alexr1) 2014-07-06 19:10:51.664-0500

Related to ASTERISK-19143

Issue outstanding over a year later on -what did the other users in this thread do to workaround the issue because it doesn't seem like it was ever resolved?

Upgraded to Asterisk 11 and Issue is still present.

By: Mark Murawski (kobaz) 2014-07-08 08:17:12.761-0500

I haven't hit this bug in a very long time, but that doesn't mean it's still not around.  I use 1.8 exclusively and I may have fixed this in my local branch... I'll do some testing.

By: Lebogang Masenya (lebogangm) 2014-10-10 03:43:28.815-0500

These are backtrace files from core dumps of my Asterisk server

By: Lebogang Masenya (lebogangm) 2014-10-10 03:43:38.329-0500

I have Recently encountered a similar issue on my asterisk

We had to do some experimentation with some of the calls being seen as Spiraling calls of which the issue was resoled by setting padentic=yes, in sip.conf.

I see a similar error

"Found duplicate exten. Had %s found %s\n" on one of the extensions trying to register, and Asterisk keep segfaulting

Currently the only solution is to revert to setting "padentic=no" and the crashes stop immediately.

Please find attached a couple of backtraces that were produced form the crashes.