[Home]

Summary:ASTERISK-03392: Playing music on hold does not work - results in Floating point exception
Reporter:ksensei (ksensei)Labels:
Date Opened:2005-01-30 21:34:57.000-0600Date Closed:2008-01-15 15:24:34.000-0600
Priority:CriticalRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) asterisk-cxnet-zerosamplessegfault-iax-patch.txt
Description:I'm not sure exactly why MOH isn't working, but the fact that it isn't is resulting in a division by zero, and a crash.  In this test case, I am calling from one IaxPhone (cmapes) to another (ejean-leon) using my own * server and the IAX2 protocol.

Asterisk Console:
Calling from iaxPhone user cmapes to iaxPhone user ejean-leon:
-- Registered 'ejean-leon' (AUTHENTICATED) at 192.168.10.1:4569
-- Accepting AUTHENTICATED call from 192.168.10.34, requested format = 2, actual format = 2
-- Executing Dial("IAX2/cmapes@192.168.10.34:4569/5", "IAX2/ejean-leon|30|rm") in new stack
-- Called ejean-leon

GDB output:
(gdb) continue
Continuing.
[New Thread -1233314896 (LWP 1553)]

Program received signal SIGFPE, Arithmetic exception.
[Switching to Thread -1233314896 (LWP 1553)]
0x00fcd7c1 in calc_timestamp (p=0x820b058, ts=0, f=0xb67cbf70)
at chan_iax2.c:2896
2896 int diff = ms % (f->samples / 8);
(gdb) bt
#0 0x00fcd7c1 in calc_timestamp (p=0x820b058, ts=0, f=0xb67cbf70)
at chan_iax2.c:2896
#1 0x00fcda0d in iax2_send (pvt=0x820b058, f=0xb67cbf70, ts=0, seqno=-1,
now=0, transfer=0, final=16) at chan_iax2.c:3091
#2 0x00fcf630 in iax2_write (c=0x10, f=0xb67cbf70) at chan_iax2.c:3551
#3 0x0805d930 in ast_write (chan=0x820b6d8, fr=0xb67cbf70) at channel.c:1634
#4 0x0805dff3 in ast_activate_generator (chan=0x820b6d8, gen=0x46491c,
params=0x10) at channel.c:1554
ASTERISK-1 0x004622a6 in ast_moh_start (chan=0x0,
class=0x10 <Address 0x10 out of bounds>) at res_musiconhold.c:598
ASTERISK-2 0x0035e7fd in dial_exec (chan=0x820b6d8, data=0x35f882) at app_dial.c:883
ASTERISK-3 0x08075944 in pbx_exec (c=0x820b6d8, app=0x81db258, data=0xb67cf0c0,
newstack=0) at pbx.c:469
ASTERISK-4 0x08077be3 in pbx_extension_helper (c=0x820b6d8,
context=0x80d5c95 "Newexten", exten=0x820b924 "246", priority=1,
callerid=0x81cb3e8 "\"IaxPhone User\" <14042927963>", action=135088172)
at pbx.c:1277
ASTERISK-5 0x0807ed1f in ast_pbx_run (c=0x820b6d8) at pbx.c:1758
ASTERISK-6 0x080801b1 in pbx_thread (data=0x10) at pbx.c:1981
ASTERISK-7 0x006003ae in start_thread () from /lib/tls/libpthread.so.0
ASTERISK-8 0x001d7b6e in clone () from /lib/tls/libc.so.6
(gdb)


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

Source was obtained with cvs on v1-0

Code fix:
// KSN - BOMC - Fix for div by 0
// int diff = ms % (f->samples / 8);                                 // if(diff)
//   ms += f->samples/8 - diff;                                 int diff;
int adjusted_samples = f->samples / 8;
if (adjusted_samples == 0)
{
   diff = 0;
   ast_log(LOG_WARNING, "calc_timestamp: call %d/%d: Working around adjusted_samples=0\n", p->callno, iaxs[p->callno]->peercallno);
}
else
   diff = ms % (adjusted_samples / 8);
if(diff)
   ms += adjusted_samples - diff;
// KSN - EOMC
Comments:By: Mark Spencer (markster) 2005-01-30 21:53:23.000-0600

Marking as resolved since this is not an issue with CVS head.

By: Russell Bryant (russell) 2005-01-30 23:26:37.000-0600

Can you attach a patch in 'diff -u' format, please?

By: Kevin P. Fleming (kpfleming) 2005-02-04 10:13:21.000-0600

Re-opening so a new patch can actually be attached (can we please get the workflow changed so "resolved" bugs can still be updated?)

By: thansen (thansen) 2005-02-04 10:46:49.000-0600

Patch to fix the mod by zero segfault. (Disclaimed as always)

edited on: 02-04-05 10:51

By: Mark Spencer (markster) 2005-02-04 11:39:43.000-0600

Marking as resolved for Russell again :)

By: Russell Bryant (russell) 2005-02-06 22:05:53.000-0600

fixed in 1.0

By: Digium Subversion (svnbot) 2008-01-15 15:24:34.000-0600

Repository: asterisk
Revision: 4976

U   branches/v1-0/channels/chan_iax2.c

------------------------------------------------------------------------
r4976 | russell | 2008-01-15 15:24:34 -0600 (Tue, 15 Jan 2008) | 2 lines

fix div by zero (bug ASTERISK-3392)

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

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