[Home]

Summary:ASTERISK-16722: Crash when assigning 2 return vallues to an ARRAY with FUNC_ODBC call
Reporter:Bruce McAlister (asgaroth)Labels:
Date Opened:2010-09-23 12:50:48Date Closed:2010-09-24 08:55:13
Priority:CriticalRegression?No
Status:Closed/CompleteComponents:Functions/func_odbc
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) backtrace.txt
Description:When an odbc returns 2 values to be set in an array refereces asterisk crashes.

****** STEPS TO REPRODUCE ******

Definition in func_odbc.conf

[IsLocalAccount]
prefix=Check
dsn=services
readsql=SELECT number, count(number) FROM numbers GROUP BY number HAVING (number ~ '${SQL_ESC(${ARG1})}$')
---------------------------------------

Definition in extensions.conf

exten => _X.,1,Set(ARRAY(Number,NumberCount)=${Check_IsLocalAccount(${EXTEN})})
exten => _X.,n,NoOp(Number=${Number} two=${NumberCount})
exten => _X.,n,HangUp()
---------------------------------------

Output on asterisk console

   -- Executing [8262900@base-out:1] SetAMAFlags("SIP/sipaccount-00000000", "BILLING") in new stack
   -- Executing [8262900@base-out:2] Set("SIP/sipaccount-00000000", "ARRAY(Number,NumberCount)=18262900,1") in new stack
bfieast01*CLI>
Disconnected from Asterisk server

I have attached a backtrace of the crash when the extension dies. It looks like the odbc query returns ok as the data listed in the set operation appears to be correct (18262900,1), so it may be something to do with the ARRAY function.

I tried setting the escapecommas option for the odbc function as well, but the system still crashes.
Comments:By: Bruce McAlister (asgaroth) 2010-09-24 06:07:53

I did some more testing and it looks like the problem may be related to the comma that is passed back by func_odbc, it looks like it needs to be escaped.

If I setup an extension as follows:

exten => _X.,1,Set(ARRAY(Status,NumCalls)=OK,0)
exten => _X.,n,NoOp(Status: ${Status} Current-Calls: ${NumCalls})

Then asterisk crashes, however, if I modify the extension to escap the comma, as follows:

exten => _X.,n,Set(ARRAY(Status,NumCalls)=OK\,0)
exten => _X.,n,NoOp(Status: ${Status} Current-Calls: ${NumCalls})

Then the assignment operation works as expected.

I tried to add the escapecommas=yes parameter to odbc function in question but it has no effect on asterisk crashing. Is it possible that it is not escaping the comma when returning the data back to the ARRAY faunction?

By: Tilghman Lesher (tilghman) 2010-09-24 08:46:52

func_odbc requires that you have
[compat]
app_set=1.6
in asterisk.conf.  Please confirm that setting.

By: Digium Subversion (svnbot) 2010-09-24 08:53:31

Repository: asterisk
Revision: 288712

U   branches/1.6.2/funcs/func_strings.c

------------------------------------------------------------------------
r288712 | tilghman | 2010-09-24 08:53:31 -0500 (Fri, 24 Sep 2010) | 5 lines

Solaris won't printf a NULL.

(closes issue ASTERISK-16722)
Reported by: asgaroth

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

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

By: Digium Subversion (svnbot) 2010-09-24 08:54:18

Repository: asterisk
Revision: 288713

_U  branches/1.8/
U   branches/1.8/funcs/func_strings.c

------------------------------------------------------------------------
r288713 | tilghman | 2010-09-24 08:54:18 -0500 (Fri, 24 Sep 2010) | 12 lines

Merged revisions 288712 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.6.2

........
 r288712 | tilghman | 2010-09-24 08:53:30 -0500 (Fri, 24 Sep 2010) | 5 lines
 
 Solaris won't printf a NULL.
 
 (closes issue ASTERISK-16722)
  Reported by: asgaroth
........

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

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

By: Digium Subversion (svnbot) 2010-09-24 08:55:12

Repository: asterisk
Revision: 288714

_U  trunk/
U   trunk/funcs/func_strings.c

------------------------------------------------------------------------
r288714 | tilghman | 2010-09-24 08:55:12 -0500 (Fri, 24 Sep 2010) | 19 lines

Merged revisions 288713 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8

................
 r288713 | tilghman | 2010-09-24 08:54:17 -0500 (Fri, 24 Sep 2010) | 12 lines
 
 Merged revisions 288712 via svnmerge from
 https://origsvn.digium.com/svn/asterisk/branches/1.6.2
 
 ........
   r288712 | tilghman | 2010-09-24 08:53:30 -0500 (Fri, 24 Sep 2010) | 5 lines
   
   Solaris won't printf a NULL.
   
   (closes issue ASTERISK-16722)
    Reported by: asgaroth
 ........
................

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

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