Rockbox

Tasklist

FS#10067 - FLAC, Divide by zero error

Attached to Project: Rockbox
Opened by Frank Grisafi (JobVanDam) - Sunday, 29 March 2009, 03:23 GMT
Last edited by Magnus Holmgren (learman) - Sunday, 29 March 2009, 15:09 GMT
Task Type Bugs
Category Music playback
Status Closed
Assigned To No-one
Operating System All players
Severity Low
Priority Normal
Reported Version Version 3.1
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Using Rockbox 3.2, when playing FLAC files shorter than a second causes the following error:
Divide by zero at 01E56B90

Dreamlayers (Boris Gjenero) already located the source of the error so he deserves credit. Forum post of complete findings:
http://forums.rockbox.org/index.php?topic=21061.msg147362#msg147362

Here's the bug, in flac_init():

/* Calculate track length (in ms) and estimate the bitrate
(in kbit/s) */
fc->length = (fc->totalsamples / fc->samplerate) * 1000;

That's integer division, so if the track is shorter than a second, the result is zero. For example, here's GDB after playing Worms - Jock - Ya Can What Side Yer On.flac, Worms - Jock - Ya Numpty.flac on the r20528 5G iPod sim:

Program received signal SIGFPE, Arithmetic exception.
[Switching to thread 4880.0x818]
0x030a16d5 in flac_init (fc=0x6adfcb0, first_frame_offset=0)
at /home/Boris/rockbox-dev/apps/codecs/flac.c:175
175 fc->bitrate = ((fc->filesize-fc->metadatalength) * 8 ) / fc->length;
(gdb) p fc->totalsamples
$1 = 16383
(gdb) p fc->samplerate
$2 = 22050
(gdb)

Attached are 3, royalty free, FLAC files that are shorter than a second so whoever takes up this task can test it out.
If any other information is needed please don't hesitate to ask.
This task depends upon

Closed by  Magnus Holmgren (learman)
Sunday, 29 March 2009, 15:09 GMT
Reason for closing:  Fixed
Additional comments about closing:  Fixed in r20567.
2014-08-18: A request to re-open the task has been made. Reason for request: I still get this error on FLAC files on 3.13 stable release, or on the latest dev build (18/08/2014) a9713d8-140818. It tells me something like "Divide by zero at 308pc:9080A648 sp:30804Dbt end". The only difference between the stable release and the dev build, is that in the first case, it shutdowns my Sansa Clip+ (which won’t boot again until a hard reset), which is not the case in the second case.

Loading...