Opened 13 years ago

Closed 13 years ago

#324 closed defect (fixed)

floating point exception while generation of 1s silence

Reported by: Schweinebacke Owned by: Michael Niedermayer
Priority: critical Component: ffmpeg
Version: git-master Keywords: fpe regression
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: yes

Description

ffmpeg -f s16le -i /dev/zero -ab 224000 -ar 48000 -ac 2 -t 1 test.ac3
or
ffmpeg -f s16le -i /dev/zero -ab 224000 -ar 48000 -ac 2 -t 1 test.wav
results in a floating point exception:

ffmpeg version 0.8, Copyright (c) 2000-2011 the FFmpeg developers
  built on Jun 23 2011 09:35:04 with gcc 4.5.0 20100604 [gcc-4_5-branch revision 160292]
  configuration: --shlibdir=/usr/lib64 --prefix=/usr --mandir=/usr/share/man --libdir=/usr/lib64 --enable-shared --disable-static --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libspeex --enable-libxvid --enable-postproc --enable-gpl --enable-x11grab --extra-cflags='-fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -fPIC -I/usr/include/gsm' --enable-debug --disable-stripping --enable-libgsm --enable-libschroedinger --enable-libdirac --enable-avfilter --enable-libvpx --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libdc1394 --enable-pthreads --enable-librtmp
  libavutil    51.  9. 1 / 51.  9. 1
  libavcodec   53.  7. 0 / 53.  7. 0
  libavformat  53.  4. 0 / 53.  4. 0
  libavdevice  53.  1. 1 / 53.  1. 1
  libavfilter   2. 23. 0 /  2. 23. 0
  libswscale    2.  0. 0 /  2.  0. 0
  libpostproc  51.  2. 0 / 51.  2. 0
Ignoring attempt to set invalid timebase for st:0
[s16le @ 0x635660] Estimating duration from bitrate, this may be inaccurate     
Input #0, s16le, from '/dev/zero':                                              
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0.0: Audio: pcm_s16le, 1 channels, s16
[ac3 @ 0x62f220] channel_layout not specified
[ac3 @ 0x62f220] No channel layout specified. The encoder will guess the layout, but it might be incorrect.                                                     
Output #0, ac3, to 'test.ac3':                                                  
  Metadata:
    encoder         : Lavf53.4.0
    Stream #0.0: Audio: ac3, 48000 Hz, stereo, s16, 224 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
Press [q] to stop, [?] for help
floating point exception

Change History (4)

comment:1 by Carl Eugen Hoyos, 13 years ago

Keywords: fpe regression added; floating point exception removed
Reproduced by developer: set
Status: newopen
Version: 0.8git-master

Workaround is to use

$ ffmpeg -ar 48000 -f s16le -i /dev/zero -ar 48000 -t 1 out.wav
(gdb) r -f s16le -i /dev/zero -ar 48000 -t 1 out.wav
Starting program: /home/cehoyos/Projects/FFmpeg/ffmpeg_g -f s16le -i /dev/zero -ar 48000 -t 1 out.wav
[Thread debugging using libthread_db enabled]
ffmpeg version N-31094-g8c0cbb0, Copyright (c) 2000-2011 the FFmpeg developers
  built on Jun 30 2011 08:31:56 with gcc 4.5.3
  configuration: --cc='/usr/local/gcc-4.5.3/bin/gcc -m32'
  libavutil    51. 10. 0 / 51. 10. 0
  libavcodec   53.  7. 0 / 53.  7. 0
  libavformat  53.  4. 0 / 53.  4. 0
  libavdevice  53.  2. 0 / 53.  2. 0
  libavfilter   2. 24. 0 /  2. 24. 0
  libswscale    2.  0. 0 /  2.  0. 0
Ignoring attempt to set invalid timebase for st:0
[s16le @ 0x8c69340] Estimating duration from bitrate, this may be inaccurate
Input #0, s16le, from '/dev/zero':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0.0: Audio: pcm_s16le, 1 channels, s16
Output #0, wav, to 'out.wav':
  Metadata:
    encoder         : Lavf53.4.0
    Stream #0.0: Audio: pcm_s16le, 48000 Hz, 1 channels, s16, 768 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
Press [q] to stop, [?] for help

Program received signal SIGFPE, Arithmetic exception.
0x085bc9f3 in __udivmoddi4 (rp=0x0, d=0, n=1024000000) at ../../.././libgcc/../gcc/libgcc2.c:895
895     ../../.././libgcc/../gcc/libgcc2.c: No such file or directory.
        in ../../.././libgcc/../gcc/libgcc2.c
(gdb) bt
#0  0x085bc9f3 in __udivmoddi4 (rp=0x0, d=0, n=1024000000) at ../../.././libgcc/../gcc/libgcc2.c:895
#1  __divdi3 (rp=0x0, d=0, n=1024000000) at ../../.././libgcc/../gcc/libgcc2.c:1093
#2  0x08050480 in output_packet (ist=0x8c74058, ist_index=0, ost_table=0x8c76cc0, nb_ostreams=1, pkt=0xffffcda0) at ffmpeg.c:1599
#3  0x08053a0f in transcode (nb_output_files=1, input_files=0x8c63008, nb_input_files=1, stream_maps=0x0, nb_stream_maps=0, output_files=0x870a9c0) at ffmpeg.c:2780
#4  0x08058c85 in main (argc=<value optimized out>, argv=<value optimized out>) at ffmpeg.c:4578

comment:2 by Michael Niedermayer, 13 years ago

Which commit introduced the regression?

comment:3 by Carl Eugen Hoyos, 13 years ago

Regression since:

commit d7ee44024c96ebdbcd718885a77e9a07779df54c
Author: Anton Khirnov <anton@khirnov.net>
Date: Wed Jun 15 08:00:03 2011 +0200

ffmpeg: don't abuse a global for passing samplerate from input to output

It's broken with multiple files or audio streams.

This removes the default samplerate of 44100 for raw input, hence all
the FATE changes.

comment:4 by Stefano Sabatini, 13 years ago

Analyzed by developer: set
Resolution: fixed
Status: openclosed

Fixed in commit:

commit aa638b4600e1fa7a1b64323b8228c459af644a47
Author: Stefano Sabatini <stefasab@gmail.com>
Date:   Thu Oct 27 01:38:21 2011 +0200

    rawdec: add check on sample_rate
    
    Prevent error condition in case sample_rate is unset or set to a negative
    value. In particular, fix divide-by-zero error occurring in ffmpeg due to
    sample_rate set to 0 in output_packet(), in code:
    
                    ist->next_pts += ((int64_t)AV_TIME_BASE * ist->st->codec->frame_size) /
                        ist->st->codec->sample_rate;
    
    Fix trac ticket #324.

The user is forced to specify a samplerate, the default value of 0 is rejected, and the FPE is thus avoided.

Note: See TracTickets for help on using tickets.