[x264-devel] Re: x264 crashes on hyperthreaded Intel processors

Loren Merritt lorenm at u.washington.edu
Fri Sep 15 17:42:05 CEST 2006


On 9/15/06, Vladislav Naumov <vladislav.naumov at gmail.com> wrote:
> Last SVN versions of x264 crash on hyperthreaded Intel processors.
> this is revison 564 (few previous did crash too)
> on Intel(R) Pentium(R) 4 CPU 2.80GHz
> Linux kernel Linux 2.6.17.13-skas3-v9-pre9 #1 SMP PREEMPT
> Debian 3.1 "sarge"
>
> I tested on several processors, failed only on Pentium with HT:

Does this fix it?

--Loren Merritt
-------------- next part --------------
Index: encoder/me.c
===================================================================
--- encoder/me.c	(revision 562)
+++ encoder/me.c	(working copy)
@@ -467,7 +467,7 @@
             int enc_dc[4];
             int sad_size = i_pixel <= PIXEL_8x8 ? PIXEL_8x8 : PIXEL_4x4;
             int delta = x264_pixel_size[sad_size].w;
-            uint16_t *ads = alloca((max_x-min_x+8) * sizeof(uint16_t));
+            uint16_t *ads = x264_alloca((max_x-min_x+8) * sizeof(uint16_t));
 
             h->pixf.sad_x4[sad_size]( zero, m->p_fenc[0], m->p_fenc[0]+delta,
                 m->p_fenc[0]+delta*FENC_STRIDE, m->p_fenc[0]+delta+delta*FENC_STRIDE,
Index: common/pixel.c
===================================================================
--- common/pixel.c	(revision 562)
+++ common/pixel.c	(working copy)
@@ -379,8 +379,8 @@
 {
     int x, y, z;
     float ssim = 0.0;
-    int (*sum0)[4] = alloca(4 * (width/4+3) * sizeof(int));
-    int (*sum1)[4] = alloca(4 * (width/4+3) * sizeof(int));
+    int (*sum0)[4] = x264_alloca(4 * (width/4+3) * sizeof(int));
+    int (*sum1)[4] = x264_alloca(4 * (width/4+3) * sizeof(int));
     width >>= 2;
     height >>= 2;
     z = 0;
Index: common/common.h
===================================================================
--- common/common.h	(revision 562)
+++ common/common.h	(working copy)
@@ -37,9 +37,11 @@
 #define X264_VERSION "" // no configure script for msvc
 #endif
 
-/* alloca */
+/* alloca: force 16byte alignment */
 #ifdef _MSC_VER
-#define	alloca	_alloca
+#define x264_alloca(x) (void*)(((intptr_t)_alloca((x)+15)+15)&~15)
+#else
+#define x264_alloca(x) (void*)(((intptr_t) alloca((x)+15)+15)&~15)
 #endif
 
 /* threads */


More information about the x264-devel mailing list