After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 566250 - [ffdec_aac] Crash in gst_ffmpegdec_audio_frame
[ffdec_aac] Crash in gst_ffmpegdec_audio_frame
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-libav
0.10.x
Other All
: High critical
: 0.10.11
Assigned To: GStreamer Maintainers
GStreamer Maintainers
: 563463 566470 572004 574044 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2009-01-02 01:02 UTC by Mike Auty
Modified: 2012-07-10 14:14 UTC
See Also:
GNOME target: ---
GNOME version: 2.25/2.26


Attachments
Output from "gst-inspect-0.10 ffdec_aac" (1.93 KB, text/plain)
2009-01-02 12:03 UTC, Mike Auty
  Details
New output from "gst-inspect-0.10 ffdec_aac" (1.93 KB, text/plain)
2009-01-02 12:34 UTC, Mike Auty
  Details
qtdemux: Set stream-format=raw on AAC caps (1.09 KB, patch)
2010-03-08 18:03 UTC, Thiago Sousa Santos
committed Details | Review
ffdec_aac: Do not parse raw format (2.59 KB, patch)
2010-03-08 18:06 UTC, Thiago Sousa Santos
none Details | Review

Description Mike Auty 2009-01-02 01:02:41 UTC
Version: 2.24.2

What were you doing when the application crashed?
Playing any .mp4 file in totem


Distribution: Gentoo Base System release 2.0.0
Gnome Release: 2.24.2 2008-11-28 (Gentoo)
BugBuddy Version: 2.24.2

System: Linux 2.6.28 #1 SMP PREEMPT Thu Dec 25 00:40:22 GMT 2008 i686
X Vendor: The X.Org Foundation
X Vendor Release: 10503000
Selinux: No
Accessibility: Disabled
GTK+ Theme: Clearlooks
Icon Theme: gnome

Memory status: size: 139239424 vsize: 139239424 resident: 49070080 share: 18964480 rss: 49070080 rss_rlim: 18446744073709551615
CPU usage: start_time: 1230858095 rtime: 84 utime: 80 stime: 4 cutime:0 cstime: 0 timeout: 0 it_real_value: 0 frequency: 100

Backtrace was generated from '/usr/bin/totem'

[?1034h[Thread debugging using libthread_db enabled]
[New Thread 0xb59d2940 (LWP 16581)]
[New Thread 0xb0e2bb90 (LWP 17204)]
[New Thread 0xb1669b90 (LWP 17110)]
[New Thread 0xb1ec7b90 (LWP 17078)]
[New Thread 0xb26c8b90 (LWP 17073)]
[New Thread 0xb3e62b90 (LWP 16986)]
[New Thread 0xb4990b90 (LWP 16837)]
0xffffe424 in __kernel_vsyscall ()

Thread 5 (Thread 0xb26c8b90 (LWP 17073))

  • #0 __kernel_vsyscall
  • #1 waitpid
    from /lib/libpthread.so.0
  • #2 IA__g_spawn_sync
    at gspawn.c line 382
  • #3 IA__g_spawn_command_line_sync
    at gspawn.c line 694
  • #4 run_bug_buddy
    at gnome-breakpad.cc line 223
  • #5 check_if_gdb
    at gnome-breakpad.cc line 292
  • #6 bugbuddy_segv_handle
    at gnome-breakpad.cc line 84
  • #7 <signal handler called>
  • #8 float_to_int16_interleave_misc_sse2
    at libavcodec/i386/dsputil_mmx.c line 2310
  • #9 aac_decode_frame
    at libavcodec/aac.c line 1597
  • #10 avcodec_decode_audio2
    at libavcodec/utils.c line 960
  • #11 gst_ffmpegdec_audio_frame
    at gstffmpegdec.c line 1790
  • #12 gst_ffmpegdec_frame
    at gstffmpegdec.c line 1907
  • #13 gst_ffmpegdec_chain
    at gstffmpegdec.c line 2306
  • #14 gst_pad_chain_unchecked
    at gstpad.c line 3877
  • #15 gst_pad_push
    at gstpad.c line 4045
  • #16 gst_queue_loop
    at gstqueue.c line 1047
  • #17 gst_task_func
    at gsttask.c line 192
  • #18 g_thread_pool_thread_proxy
    at gthreadpool.c line 265
  • #19 g_thread_create_proxy
    at gthread.c line 635
  • #20 start_thread
    at pthread_create.c line 297
  • #21 clone
    at ../sysdeps/unix/sysv/linux/i386/clone.S line 130




----------- .xsession-errors (190039 sec old) ---------------------
ERROR: could not get file id for /home/mike/cvs/gentoo-x86/app-text/mpage/files - unable to continue indexing this file
ERROR: execution of prepared query CreateService failed due to constraint failed with return code 19
ERROR: CreateService uri is /home/mike/cvs/gentoo-x86/app-text/mbtpdfasm/files
ERROR: could not get file id for /home/mike/cvs/gentoo-x86/app-text/mbtpdfasm/files - unable to continue indexing this file
ERROR: execution of prepared query CreateService failed due to constraint failed with return code 19
ERROR: CreateService uri is /home/mike/cvs/gentoo-x86/app-text/ocrad/files
ERROR: could not get file id for /home/mike/cvs/gentoo-x86/app-text/ocrad/files - unable to continue indexing this file
ERROR: execution of prepared query CreateService failed due to constraint failed with return code 19
ERROR: CreateService uri is /home/mike/cvs/gentoo-x86/app-text/pinfo/files
ERROR: could not get file id for /home/mike/cvs/gentoo-x86/app-text/pinfo/files - unable to continue indexing this file
ERROR: execution of prepared query CreateService failed due to constraint failed with return code 19
ERROR: CreateService uri is /home/mike/cvs/gentoo-x86/app-text/silvercity/files
ERROR: could not get file id for /home/mike/cvs/gentoo-x86/app-text/silvercity/files - unable to continue indexing this file
...Too much output, ignoring rest...
--------------------------------------------------
Comment 1 Mike Auty 2009-01-02 01:16:26 UTC
Ok, a little more information on this one:

* Happens with any .mp4 file.
* Occurs with "gst-launch-0.10 playbin uri=blah.mp4", so it's not totem.
* Plays fine in mplayer and xine, so I doubt it's directly an ffmpeg issue.

I'm happy to provide any further information that I can to help, just let me know what...  5:)
Comment 2 Philip Withnall 2009-01-02 09:50:59 UTC
Similar to bug #563463.

Could you paste here the full output of `gst-inspect-0.10 ffdec_aac` please?
Comment 3 Mike Auty 2009-01-02 12:03:31 UTC
Created attachment 125624 [details]
Output from "gst-inspect-0.10 ffdec_aac"

Yep, this was built on Gentoo and therefore probably makes use of the system ffmpeg rather than the pre-packaged copy.  Feel free to close this bug if you can't help.

In case you are interested, I checked the difference between this and different machine that works fine, the only change in the output of gst-inspect was the has change_state() function goes from 0xb79a47e0 (bad) to 0xb7b0f00b (good), but of course they're different CPUs, etc so I imagine the binaries would be different anyway.

From the looks of it (and gdb just after the segfault), it appears to be segfaulting in ffmpeg:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb1bffb90 (LWP 9275)]
0xb2455c56 in float_to_int16_interleave_misc_sse2 (dst=<value optimized out>, 
    src=0x96b8150, len=1024, channels=4) at libavcodec/i386/dsputil_mmx.c:2310
2310	libavcodec/i386/dsputil_mmx.c: No such file or directory.
	in libavcodec/i386/dsputil_mmx.c

Also, after bug-buddy's collected the crash data, these two lines appear on the console:

Cannot access memory at address 0xc
Cannot access memory at address 0xc

Anyway, as I say, I understand if you have to close this bug as unsupported, but if there is any more information you want, just ask...  5:)
Comment 4 Mike Auty 2009-01-02 12:31:05 UTC
Ok, scratch that, I rebuilt gst-plugins-ffmpeg without the system ffmpeg stuff, and I still get the same problem.  Here's the new stack trace:

Distribution: Gentoo Base System release 2.0.0
Gnome Release: 2.24.2 2008-11-28 (Gentoo)
BugBuddy Version: 2.24.2

System: Linux 2.6.28 #1 SMP PREEMPT Thu Dec 25 00:40:22 GMT 2008 i686
X Vendor: The X.Org Foundation
X Vendor Release: 10503000
Selinux: No
Accessibility: Disabled
GTK+ Theme: Clearlooks
Icon Theme: gnome

Memory status: size: 141254656 vsize: 141254656 resident: 55242752 share: 24018944 rss: 55242752 rss_rlim: 18446744073709551615
CPU usage: start_time: 1230899023 rtime: 90 utime: 84 stime: 6 cutime:7 cstime: 6 timeout: 0 it_real_value: 0 frequency: 100

Backtrace was generated from '/usr/bin/totem'

[Thread debugging using libthread_db enabled]
[New Thread 0xb5895940 (LWP 22058)]
[New Thread 0xb0fe7b90 (LWP 22065)]
[New Thread 0xb1825b90 (LWP 22064)]
[New Thread 0xb2072b90 (LWP 22063)]
[New Thread 0xb2873b90 (LWP 22062)]
[New Thread 0xb3d25b90 (LWP 22061)]
[New Thread 0xb4853b90 (LWP 22060)]
0xffffe424 in __kernel_vsyscall ()

Thread 5 (Thread 0xb2873b90 (LWP 22062))

  • #0 __kernel_vsyscall
  • #1 waitpid
    from /lib/libpthread.so.0
  • #2 IA__g_spawn_sync
    at gspawn.c line 382
  • #3 IA__g_spawn_command_line_sync
    at gspawn.c line 694
  • #4 run_bug_buddy
    at gnome-breakpad.cc line 223
  • #5 check_if_gdb
    at gnome-breakpad.cc line 292
  • #6 bugbuddy_segv_handle
    at gnome-breakpad.cc line 84
  • #7 <signal handler called>
  • #8 float_to_int16_interleave_misc_sse2
    at libavcodec/i386/dsputil_mmx.c line 2289
  • #9 aac_decode_frame
    at libavcodec/aac.c line 1446
  • #10 avcodec_decode_audio2
    at libavcodec/utils.c line 953
  • #11 gst_ffmpegdec_audio_frame
    at gstffmpegdec.c line 1790
  • #12 gst_ffmpegdec_frame
    at gstffmpegdec.c line 1907
  • #13 gst_ffmpegdec_chain
    at gstffmpegdec.c line 2306
  • #14 gst_pad_chain_unchecked
    at gstpad.c line 3877
  • #15 gst_pad_push
    at gstpad.c line 4045
  • #16 gst_queue_loop
    at gstqueue.c line 1047
  • #17 gst_task_func
    at gsttask.c line 192
  • #18 g_thread_pool_thread_proxy
    at gthreadpool.c line 265
  • #19 g_thread_create_proxy
    at gthread.c line 635
  • #20 start_thread
    at pthread_create.c line 297
  • #21 clone
    at ../sysdeps/unix/sysv/linux/i386/clone.S line 130




----------- .xsession-errors (32472 sec old) ---------------------
ERROR: could not get file id for /home/mike/cvs/gentoo-x86/net-irc/kvirc/files - unable to continue indexing this file
ERROR: execution of prepared query CreateService failed due to constraint failed with return code 19
ERROR: CreateService uri is /home/mike/cvs/gentoo-x86/net-irc/xchat/files
ERROR: could not get file id for /home/mike/cvs/gentoo-x86/net-irc/xchat/files - unable to continue indexing this file
ERROR: execution of prepared query CreateService failed due to constraint failed with return code 19
ERROR: CreateService uri is /home/mike/cvs/gentoo-x86/net-irc/rhapsody/files
ERROR: could not get file id for /home/mike/cvs/gentoo-x86/net-irc/rhapsody/files - unable to continue indexing this file
ERROR: execution of prepared query CreateService failed due to constraint failed with return code 19
ERROR: CreateService uri is /home/mike/cvs/gentoo-x86/net-irc/xchat-gnome/files
ERROR: could not get file id for /home/mike/cvs/gentoo-x86/net-irc/xchat-gnome/files - unable to continue indexing this file
ERROR: execution of prepared query CreateService failed due to constraint failed with return code 19
ERROR: CreateService uri is /home/mike/cvs/gentoo-x86/net-irc/ptlink-services/files
ERROR: could not get file id for /home/mike/cvs/gentoo-x86/net-irc/ptlink-services/files - unable to continue indexing this file
...Too much output, ignoring rest...
--------------------------------------------------
Comment 5 Mike Auty 2009-01-02 12:34:29 UTC
Created attachment 125626 [details]
New output from "gst-inspect-0.10 ffdec_aac"

And here's the new gst-inspect-0.10 ffdec_aac output.  (Again the change_state function address changes)...

If there's anything else I can provide, just shout...  5:)
Comment 6 Philip Withnall 2009-01-02 12:45:44 UTC
Oh, that's interesting. Forwarding to the GStreamer people.
Comment 7 Jonathan Matthew 2009-01-05 02:09:37 UTC
*** Bug 566470 has been marked as a duplicate of this bug. ***
Comment 8 Reinout van Schouwen 2009-01-25 10:50:10 UTC
I've encountered this crash while trying to play a Youtube clip with swfdec in Mandriva Cooker. :(
Comment 9 Edward Hervey 2009-03-04 19:13:11 UTC
*** Bug 574044 has been marked as a duplicate of this bug. ***
Comment 10 Edward Hervey 2009-03-04 19:14:49 UTC
*** Bug 572004 has been marked as a duplicate of this bug. ***
Comment 11 Edward Hervey 2009-03-04 19:59:45 UTC
I can reproduce this with latest git version...

I think this is all related to the following:

0:00:01.460673597 19511       0x8560d0 INFO                ffmpeg :0:: More than one AAC RDB per ADTS frame is not implemented. Update your FFmpeg version to the newest one from SVN. If the problem still occurs, it means that your file has a feature which has not been implemented.
0:00:01.460700972 19511       0x8560d0 INFO                ffmpeg :0:: 
0:00:01.460719688 19511       0x8560d0 ERROR               ffmpeg :0:: Error decoding AAC frame header.

but we then carry on to try decoding the stream !
Comment 12 Edward Hervey 2009-03-04 20:06:29 UTC
So this only happens on some files and not all AAC file.

It's because of that error but us not detecting that :(

We'll have to either:
* ask the ffmpeg people how to properly detect that (...)
* put a hack in for AAC whenever there's a -1 return.
Comment 13 Edward Hervey 2009-03-04 20:13:40 UTC
Author: Edward Hervey <bilboed@bilboed.com>
Date:   Wed Mar 4 21:10:22 2009 +0100

    gstffmpegdec: Abort on first failure by AAC decoder. Fixes #566250.
    
    The problem is that the ffmpeg aac decoder fails... but still accepts
    the following buffers as if nothing happened. But because some things
    were not properly set in the internal code, all hell breaks loose.

diff --git a/ext/ffmpeg/gstffmpegdec.c b/ext/ffmpeg/gstffmpegdec.c
index 0bd5879..304604b 100644
--- a/ext/ffmpeg/gstffmpegdec.c
+++ b/ext/ffmpeg/gstffmpegdec.c
@@ -1858,6 +1858,13 @@ gst_ffmpegdec_audio_frame (GstFFMpegDec * ffmpegdec,
     *outbuf = NULL;
   }
 
+  /* If we don't error out after the first failed read with the AAC decoder,
+   * we must *not* carry on pushing data, else we'll cause segfaults... */
+  if ((len == -1) && (oclass->in_plugin->id == CODEC_ID_AAC)) {
+    GST_WARNING_OBJECT (ffmpegdec, "Decoding of AAC stream by FFMPEG failed.");
+    *ret = GST_FLOW_ERROR;
+  }
+
 beach:
   GST_DEBUG_OBJECT (ffmpegdec, "return flow %d, out %p, len %d",
       *ret, *outbuf, len);

Comment 14 Mike Auty 2009-03-04 20:17:47 UTC
Just as a sidenote, I wondered why I'd previously been able to play these files, and my guess is I previously had gst-plugins-faad.  Reinstalling gst-plugins-faad means that the thumbnailer and totem can see the videos fine.

I'll give the patch a try (after again removing gst-plugins-faad)...
Comment 15 Mike Auty 2009-03-04 20:34:32 UTC
I tried applying the patch to 0.10.6, and it says that oclass is undefined there.  I looked through the webgit page [1] and couldn't see it defined in that function either.  Is the patch correct?

[1] http://cgit.freedesktop.org/gstreamer/gst-ffmpeg/tree/ext/ffmpeg/gstffmpegdec.c
Comment 16 Tim-Philipp Müller 2009-03-04 21:00:42 UTC
[I took the liberty to fix the build in git after the recent commit.]

Apologies if I'm missing something here, but ...

 - aren't you returning a GST_FLOW_ERROR here without posting
   a meaningful STREAM/DECODE error message on the bus via
   GST_ELEMENT_ERROR? (resulting in an ugly 'internal flow
   error' messsage)

 - if ffmpeg fails to decode some AAC streams, shouldn't it
   have no rank at all? (So applications have a chance to
   ask for a more decent decoder to be installed)
Comment 17 Mike Auty 2009-03-04 21:30:38 UTC
Well, the two patches combined now compile, but I'm still experiencing the segfault.  You can see from the backtrace in_plugin's definitely being passed as an argument, but the issue still arises:

  • #7 <signal handler called>
  • #8 float_to_int16_interleave_misc_sse2
    at libavcodec/i386/dsputil_mmx.c line 2289
  • #9 aac_decode_frame
    at libavcodec/aac.c line 1446
  • #10 avcodec_decode_audio2
    at libavcodec/utils.c line 953
  • #11 gst_ffmpegdec_audio_frame
    at gstffmpegdec.c line 1790

Comment 18 Edward Hervey 2009-03-05 11:19:20 UTC
After chatting with the ffmpeg aac author, there's no way to figure out before hand whether it can handle a certain stream without decoding it.

We therefore set it's rank to NONE until it can handle the full specs (or at least can report before decoding whether it can handle a given stream or not).

commit eeffd7b87feaa1e6076b6110419fd0455bf64b6f
Author: Edward Hervey <bilboed@bilboed.com>
Date:   Thu Mar 5 12:09:32 2009 +0100

    gstffmpegdec: Set the rank of the AAC decoder to NONE.
    
    It will stay this way until the ffmpeg aac decoder can report before decoding
    whether it can handle a given stream or not.

Comment 19 Alex Converse 2009-03-07 19:28:36 UTC
The file you sent me does not crash vanilla FFmpeg. I think GStreamer Is doing something funny. Particularly I think that GStreamer is forcing ADTS parsing when it shouldn't be. 

The operative word in:

"More
than one AAC RDB per ADTS frame is not implemented. Update your FFmpeg version
to the newest one from SVN. If the problem still occurs, it means that your
file has a feature which has not been implemented."

is ADTS as in Audio Data Transport Stream as in not MP4. 

GStreamer should not parse the file as ADTS nor tell FFmpeg to try to parse it as ADTS.
Comment 20 Edward Hervey 2009-03-08 09:50:50 UTC
*sigh*... indeed, if we don't use an av_parser for AAC in gstffmpegdec.. it works fine.

How does one figure out if you need or not a av_parser for a given codec ???
Comment 21 Edward Hervey 2009-03-08 09:56:47 UTC
*** Bug 563463 has been marked as a duplicate of this bug. ***
Comment 22 Alex Converse 2010-01-22 18:53:05 UTC
I'm going to add what we discussed on IRC today:

For AAC you only need the parser if it is raw ADTS.

AAC in mov -> no parser
AAC in mkv -> no parser
whole ADTS frames shoved in mov/mkv -> no parser
Raw ADTS -> parser
Comment 23 Robert Swain 2010-03-08 08:35:41 UTC
Did this ever get fixed so that FFmpeg's AAC decoder is used and used properly? HE AAC v1 support was committed very recently and should be in the FFmpeg 0.6 release. I expect Alex will get PS working fairly quickly as it's much simpler than SBR. It still remains that FFmpeg's AAC decoder is actively maintained and performs much faster than FAAD. If you report real bugs in the decoder, they will get addressed.
Comment 24 Edward Hervey 2010-03-08 09:19:57 UTC
I just checked, the aac caps should have a 'framed' property in it.

IF present AND True => don't use the parser
IF absent OR False => use the parser

AFAICS, only qtdemux seems to properly set those flags, therefore another option could be to force ffdec_aac to only accept 'framed=True' which should force the standalone aacparser to be used.
Comment 25 Tim-Philipp Müller 2010-03-08 09:40:29 UTC
> AFAICS, only qtdemux seems to properly set those flags, therefore another
> option could be to force ffdec_aac to only accept 'framed=True' which should
> force the standalone aacparser to be used.

I think you'll find that that's not how it works - it will either plug aacparse all the time (as long as its rank is higher than any decoder) or not at all (current situation, since rank is NONE). Decodebin2 is not aware of parsers and can't even handle the case of not plugging the same parser twice if the parser accepts both parsed and unparsed input ;-)
Comment 26 Thiago Sousa Santos 2010-03-08 12:37:22 UTC
It seems that qtdemux doesn't put the aac stream-format on the caps. And ffdec_aac doesn't care for it. We should make qtdemux add stream-format=raw for AAC streams (as that is the expected way to store in qt files AFAIK) and ffdec_aac should check it to decide if it should call av_parse or not on that stream.


btw, why is this marked as fixed? It still crashes for me.
Comment 27 Thiago Sousa Santos 2010-03-08 18:03:51 UTC
Created attachment 155573 [details] [review]
qtdemux: Set stream-format=raw on AAC caps

Adds the stream-format to qtdemux src caps for AAC
Comment 28 Thiago Sousa Santos 2010-03-08 18:06:21 UTC
Created attachment 155574 [details] [review]
ffdec_aac: Do not parse raw format

Disable AAC parser unless we're sure it is not a raw
stream. Don't know how essential having this parser here
is. One could argue that we should only disable it when
we're sure it is raw.
Comment 29 Edward Hervey 2010-03-11 12:21:22 UTC
Looks good to me, can you also re-enable the AAC decoder with that second patch ? It's currently got a rank of NONE
Comment 30 Thiago Sousa Santos 2010-03-11 13:19:52 UTC
Pushed.

Module: gst-plugins-good
Branch: master
Commit: 145b3a3079a8abcb7bb105e348f63b38927ae2ce
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=145b3a3079a8abcb7bb105e348f63b38927ae2ce

Author: Thiago Santos <thiago.sousa.santos@collabora.co.uk>
Date:   Mon Mar  8 14:57:17 2010 -0300

qtdemux: Set stream-format=raw on AAC caps

Set stream-format=raw for AAC caps, as that is the
expected AAC format to be in this container family.

Fixes #566250

Module: gst-ffmpeg
Branch: master
Commit: c300a0a9f24a0e6b5714ab4bfe1d8fd8a5f8bbfb
URL:    http://cgit.freedesktop.org/gstreamer/gst-ffmpeg/commit/?id=c300a0a9f24a0e6b5714ab4bfe1d8fd8a5f8bbfb

Author: Thiago Santos <thiago.sousa.santos@collabora.co.uk>
Date:   Mon Mar  8 15:00:05 2010 -0300

ffdec_aac: Do not parse raw format

If the stream is 'raw' format, do not use parsers.
Re-enables the aac decoder by putting it back to default
ffdec rank.

Fixes #566250
Comment 31 Thiago Sousa Santos 2010-03-11 13:21:51 UTC
Comment on attachment 155574 [details] [review]
ffdec_aac: Do not parse raw format

obsoleting this, but an improved version has been pushed.

This improved version is basically the same, but puts aac decoder back to ffdec default rank.
Comment 32 Wim Taymans 2012-07-10 14:14:07 UTC
Reverted again, see Bug #679639