[Home]

Summary:ASTERISK-05447: lastdigitts is never initialized which causes first DTMF tone to have a random timestamp
Reporter:Erik Tornstam (tornstam)Labels:
Date Opened:2005-11-04 03:47:37.000-0600Date Closed:2008-01-15 15:55:36.000-0600
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) debug.txt
Description:In rtp.c lastdigitts is never initialized which causes first DTMF tone to have a random timestamp.

In some receiving stacks the first DTMF digit is dropped in others all DTMF is dropped for that session.

Debuging information should allso be printed with %u as the values are unsigned.
Comments:By: Kevin P. Fleming (kpfleming) 2005-11-07 20:54:46.000-0600

I have fixed the debug output issue. There is no issue regarding lastdigitts; when the structure is allocated it is zeroed via memset(), and when the structure is reused it is reset to zero explicitly. If you can point to a specific code path where it is used without being initialized I'll gladly fix it :-)

By: Erik Tornstam (tornstam) 2005-11-08 03:00:52.000-0600

Ok, it's initialized but to a value far bigger than lastts as seen in the attached debug.txt.
(it appers less because of the signed unsigned bug in the debugging function)

Is it possible for lastdigitts to significantly bigger than lastts in a new session?

Where is lastdigitts reset to zero? I can see it in  ast_rtp_reset, but as far as I can see that function is never called.
(
grep ast_rtp_reset `find . -name \*.c`
./rtp.c:void ast_rtp_reset(struct ast_rtp *rtp)
)



By: Kevin P. Fleming (kpfleming) 2005-11-08 18:51:49.000-0600

RTP sessions are not re-used, so I don't know why someone added that function :-)

Are you getting these messages at the beginning of a new session, or a session that has been up for a while (and possibly transferred, put on/off hold, etc.)?

By: Erik Tornstam (tornstam) 2005-11-09 01:44:44.000-0600

Only at the beginning of a new session and only for the first digit pressed in that session.

Scenario:
Caller Connects to Asterisk who connects to other IVR. Asterisk is tromboning the call.
Remote IVR asks for DTMF password,
and here the bad stuff happens.
rtp.c:1136 ast_rtp_senddigit: DIGIT: 1, lastdigitts: 4294967288,  lastts: 131032, seqno 7009
rtp.c:1139 ast_rtp_senddigit: NEW lastdigitts: 131032 (My fix is to reset lastdigitts if it's bigger than lastts)
rtp.c:1136 ast_rtp_senddigit: DIGIT: 2, lastdigitts: 133112,  lastts: 133112, seqno 7025
rtp.c:1136 ast_rtp_senddigit: DIGIT: 9, lastdigitts: 137432,  lastts: 137432, seqno 7056
rtp.c:1136 ast_rtp_senddigit: DIGIT: 9, lastdigitts: 142552,  lastts: 142552, seqno 7092


My solution:
----
diff -r1.152 rtp.c
1137a1138,1143
>       ast_log(LOG_DEBUG,"DIGIT: %d, lastdigitts: %u,  lastts: %u, seqno %u\n",digit ,rtp->lastdigitts,rtp->lastts,rtp->seqno);
>         if(rtp->lastdigitts > rtp->lastts) {
>           rtp->lastdigitts = rtp->lastts;
>           ast_log(LOG_DEBUG,"NEW lastdigitts: %u\n",rtp->lastdigitts);
>         }
>



By: Kevin P. Fleming (kpfleming) 2005-11-10 22:11:22.000-0600

OK, I think I may have an idea what is happening.

Can you do two things for me:

1) Add to ast_rtp_raw_write() a check to see if ms (as returned from calc_txstamp()) is negative, and if so, print out a log message with the ms value along with the f->delivery timeval?

2) Tell us what your exact config is: incoming channel type, codecs in use...

Thanks. It appears that lastts is going 'negative' because the calculation on line 1239 is producing a negative value, which is then coerced into an 'unsigned int' and copied into lastdigitts (since it is 'greater than' its current value, which is zero).

By: Mark Spencer (markster) 2005-11-10 23:18:23.000-0600

Fixed in CVS head.

By: Digium Subversion (svnbot) 2008-01-15 15:54:38.000-0600

Repository: asterisk
Revision: 7009

U   trunk/ChangeLog
U   trunk/rtp.c

------------------------------------------------------------------------
r7009 | kpfleming | 2008-01-15 15:54:38 -0600 (Tue, 15 Jan 2008) | 2 lines

issue ASTERISK-5447

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

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

By: Digium Subversion (svnbot) 2008-01-15 15:55:35.000-0600

Repository: asterisk
Revision: 7069

U   trunk/rtp.c

------------------------------------------------------------------------
r7069 | markster | 2008-01-15 15:55:34 -0600 (Tue, 15 Jan 2008) | 2 lines

Fix wrap around for rtp (bug ASTERISK-5447)

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

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

By: Digium Subversion (svnbot) 2008-01-15 15:55:36.000-0600

Repository: asterisk
Revision: 7070

U   trunk/ChangeLog

------------------------------------------------------------------------
r7070 | kpfleming | 2008-01-15 15:55:35 -0600 (Tue, 15 Jan 2008) | 2 lines

issue ASTERISK-5447

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

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