[Home]

Summary:ASTERISK-12721: exten => s,n,SMS(sms,2a) causes seg fault
Reporter:Alec Davis (alecdavis)Labels:
Date Opened:2008-09-12 06:33:24Date Closed:2008-10-01 10:34:05
Priority:CriticalRegression?No
Status:Closed/CompleteComponents:Applications/app_sms
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) 20080916__bug13471.diff.txt
( 1) gdb.txt
Description:When ever a text comes in from a cellular trunking unit attached to a TDM400, asterisk will seg fault dropping all calls and restart.

Previously with asterisk 1.4.18, the sms application wasn't working for us, but at least didn't seg fault in 1.4.18



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

DAHDI dahdi-2.0.0-rc4 + dahdi-tools-2.0.0-rc2
Comments:By: snuffy (snuffy) 2008-09-12 07:27:12

Please provide a backtrace, if your unsure how to read doc/backtrace.txt

By: Alec Davis (alecdavis) 2008-09-14 22:48:40

back trace attached.

I believe the inital SMS sytax that I had used was incorrect, but I'd still expect the SMS app to exit gracefully, not crash asterisk.

[cellular_crashes]
exten => s,1,NoOp(Callerid = ${CALLERID(all)})
exten => s,n,GotoIf($["${CALLERID(num)}"="042111"]?SMSMessage)
exten => s,n,Macro(dialout,${TRUNK},4888)

exten => s,n,Hangup()

exten => s,n(SMSMessage),NoOp( SMS MESSAGE )
exten => s,n,SMS(sms,2a)
exten => s,n,Hangup()

Below is a now working context. I couldn't get the initial delay to be anything other than the default of 300ms, so added Answer() and Wait(3)
[cellular_works]
exten => s,1,NoOp(Callerid = ${CALLERID(all)})
exten => s,n,GotoIf($["${CALLERID(num)}"="042111"]?SMSMessage)
exten => s,n,Macro(dialout,${TRUNK},4888)

exten => s,n,Hangup()

exten => s,n(SMSMessage),NoOp( SMS MESSAGE )
exten => s,n,Answer()
exten => s,n,Wait(3)
exten => s,n,SMS(test,sat)
exten => s,n,Hangup()

By: Tilghman Lesher (tilghman) 2008-09-16 10:37:00

Let's try this patch.  This may be as simple as failing to initialize a buffer.

By: Alec Davis (alecdavis) 2008-09-17 06:02:33

1: Patch fixes seg fault.
Now with the wrong syntax "exten => s,n,SMS(sms,2a)", asterisk doesn't seg fault.

For whats it's worth prior to the fix, the first text message to come in after an asterisk stop/start didn't seg fault, but always the next text message always reliably seg faulted.

2:-----------Typo------------
Also noticed the Arguements syntax summary from 'core show application SMS' has a typo. Arguments has a 2nd 's' where I believe it should be 'r'
Perhaps also the initial delay's min(25) and max(2000) should be documented, as my 3 seconds was never going to work.

SMS(name,[a][s][t][p(d)][r][o],addr,body):

Arguments:
a  - answer, i.e. send initial FSK packet.
s  - act as service centre talking to a phone.
t  - use protocol 2 (default used is protocol 1).
p(N)  - set the initial delay to N ms (default is 300).
        addr and body are a deprecated format to send messages out.
s  - set the Status Report Request (SRR) bit.               <<<<<<
o  - the body should be coded as octets not 7-bit symbols.


3:-------------------
What is the correct syntax for SMS app to pause for 2000ms?
I'm using exten => s,n,SMS(sms,satp2000)

further to this starting at line 1793 of app_sms.c the delay always return 0, thus will then default to 300ms.

      if (!ast_strlen_zero(sms_opts[OPTION_ARG_PAUSE]))
               h.opause_0 = atoi(sms_opts[OPTION_ARG_PAUSE]);
      ast_verb(1, "set delay %dms\n", h.opause_0);    /*<<<< Testing >>>> */
      if (h.opause_0 < 25 || h.opause_0 > 2000)
               h.opause_0 = 300;       /* default 300ms */
      ast_verb(1, "initial delay %dms\n", h.opause_0);

Finally, forcing it to 2000 after the above still didn't appear to wait out 2000 ms.
      h.opause_0 = 2000;

So, similar to originally reported, is the only way to get SMS working for us.
  exten => s,n,Answer()
  exten => s,n,Wait(2)
  exten => s,n,SMS(test,sat)



By: Alec Davis (alecdavis) 2008-10-01 03:05:04

Now that 'crash' is fixed, this can be closed, other matters need cleanup.

By: Digium Subversion (svnbot) 2008-10-01 10:34:03

Repository: asterisk
Revision: 145428

U   trunk/apps/app_sms.c

------------------------------------------------------------------------
r145428 | tilghman | 2008-10-01 10:34:02 -0500 (Wed, 01 Oct 2008) | 7 lines

Initializing buffer prevents a segfault when arguments are incomplete.
(closes issue ASTERISK-12721)
Reported by: alecdavis
Patches:
      20080916__bug13471.diff.txt uploaded by Corydon76 (license 14)
Tested by: alecdavis

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

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