GNOME Bugzilla – Bug 566250
[ffdec_aac] Crash in gst_ffmpegdec_audio_frame
Last modified: 2012-07-10 14:14:07 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 ()
+ Trace 211218
Thread 5 (Thread 0xb26c8b90 (LWP 17073))
----------- .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... --------------------------------------------------
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:)
Similar to bug #563463. Could you paste here the full output of `gst-inspect-0.10 ffdec_aac` please?
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:)
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 ()
+ Trace 211232
Thread 5 (Thread 0xb2873b90 (LWP 22062))
----------- .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... --------------------------------------------------
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:)
Oh, that's interesting. Forwarding to the GStreamer people.
*** Bug 566470 has been marked as a duplicate of this bug. ***
I've encountered this crash while trying to play a Youtube clip with swfdec in Mandriva Cooker. :(
*** Bug 574044 has been marked as a duplicate of this bug. ***
*** Bug 572004 has been marked as a duplicate of this bug. ***
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 !
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.
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);
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)...
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
[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)
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:
+ Trace 213171
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.
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.
*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 ???
*** Bug 563463 has been marked as a duplicate of this bug. ***
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
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.
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.
> 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 ;-)
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.
Created attachment 155573 [details] [review] qtdemux: Set stream-format=raw on AAC caps Adds the stream-format to qtdemux src caps for AAC
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.
Looks good to me, can you also re-enable the AAC decoder with that second patch ? It's currently got a rank of NONE
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 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.
Reverted again, see Bug #679639