softdevice segfaulting on stream errors

Message ID 469395C3.4010507@o2.pl
State New
Headers

Commit Message

Artur Skawina July 10, 2007, 2:20 p.m. UTC
  Some time ago the softdevice plugin started crashing when playing video streams
containing errors, both while live viewing and watching recordings.
Today I found a transponder where it reliably occurred within seconds and decided
to investigate. The picture buffers used for video were 8-byte aligned, which
happened to work for "normal" mpeg decoding, but wasn't enough. ffmpeg was
executing SSE instructions when doing error concealment and those were segfaulting.
Fix below.

artur
  

Comments

Stefan Lucke July 11, 2007, 8:23 p.m. UTC | #1
On Tuesday 10 July 2007 16:20, Artur Skawina wrote:
> Some time ago the softdevice plugin started crashing when playing video streams
> containing errors, both while live viewing and watching recordings.
> Today I found a transponder where it reliably occurred within seconds and decided
> to investigate. The picture buffers used for video were 8-byte aligned, which
> happened to work for "normal" mpeg decoding, but wasn't enough. ffmpeg was
> executing SSE instructions when doing error concealment and those were segfaulting.
> Fix below.

Thanks, applied.
  

Patch

diff -uwp softdevice.noalign/PicBuffer.c softdevice/PicBuffer.c
--- softdevice.noalign/PicBuffer.c      2007-03-13 02:57:19.000000000 +0100
+++ softdevice/PicBuffer.c      2007-07-10 15:25:38.000000000 +0200
@@ -316,9 +316,8 @@  bool AllocatePicBuffer(sPicBuffer *buf,P

         if ( !isPlanar(pix_fmt) ) {
                 buf->stride[0]=ALIGN(pixel_size*w,16);
-                buf->pixel[0]=(uint8_t*)malloc((buf->stride[0]*h)+16);

-                if (buf->pixel[0]==NULL) {
+                if (posix_memalign(&buf->pixel[0], 16, buf->stride[0]*h+16)) {
                     printf("could not allocate memory for picture buffer!\n") ;
                     exit(-1);
                     return false;
@@ -337,9 +336,7 @@  bool AllocatePicBuffer(sPicBuffer *buf,P
             buf->stride[i]= ALIGN(pixel_size*w>>h_shift,
                             STRIDE_ALIGN<<(h_chroma_shift-h_shift));

-            buf->pixel[i]= (uint8_t*)malloc((buf->stride[i]*h>>v_shift)+16); //FIXME 16
-
-            if(buf->pixel[i]==NULL) {
+            if(posix_memalign(&buf->pixel[i], 16, (buf->stride[i]*h>>v_shift)+16)) { //FIXME 16
                     printf("could not allocate memory for picture buffer!\n") ;
                     exit(-1);
                     return false;