Package: libogre-1.7.4
Version: 1.7.4+dfsg1-6
Severity: important
Tags: upstream patch

Any program using a skeleton along a mesh will segfault (at least on amd64).
This is the same bug as #687013 which affected ogre-1.8. It is easily fixed
by applying the same patch (updated for 1.7.4).

Although it is not an RC bug, please consider requesting a freeze exception
for this fix: it affects anyone who use skeleton with a mesh (at least on
amd64) which is a use case extremely well spread.

cheers,

Nicolas Bourdaud


-- System Information:
Debian Release: wheezy/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 3.2.0-4-amd64 (SMP w/4 CPU cores)
Locale: LANG=fr_FR.utf8, LC_CTYPE=fr_FR.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages libogre-1.7.4 depends on:
ii  dpkg                      1.16.9
ii  libboost-thread1.49.0     1.49.0-3.1
ii  libc6                     2.13-35
ii  libfreeimage3             3.15.1-1+b1
ii  libfreetype6              2.4.9-1
ii  libgcc1                   1:4.7.1-7
ii  libgl1-mesa-glx [libgl1]  8.0.4-2
ii  libglu1-mesa [libglu1]    8.0.4-2
ii  libstdc++6                4.7.1-7
ii  libx11-6                  2:1.5.0-1
ii  libxaw7                   2:1.0.10-2
ii  libxrandr2                2:1.3.2-2
ii  libxt6                    1:1.1.3-1
ii  libzzip-0-13              0.13.56-1.1
ii  multiarch-support         2.13-35

libogre-1.7.4 recommends no packages.

libogre-1.7.4 suggests no packages.

-- no debconf information
Description: drop stack alignment hack that breaks with gcc-4.7
Bug: http://www.ogre3d.org/mantis/view.php?id=553
Bug-Debian: http://bugs.debian.org/687013
Origin: upstream, http://hg.libsdl.org/SDL/rev/62ff1c0a103f
Applied-Upstream: 1.8.1

# HG changeset patch
# User Holger Frydrych <h.frydr...@gmx.de>
# Date 1343895642 -7200
# Branch v1-8
# Node ID 9db0902fcff8772b5f9f6c3459430bb8a75bbe09
# Parent  5bcdaa1cf83322d5a281d1fd6752228a94d51620
Replace an ugly hack for GCC that was trying to force 16-byte stack alignment in OgreOptimisedUtilSSE, but causes trouble with recent GCC versions

--- a/OgreMain/src/OgreOptimisedUtilSSE.cpp
+++ b/OgreMain/src/OgreOptimisedUtilSSE.cpp
@@ -84,7 +84,7 @@
         OptimisedUtilSSE(void);
 
         /// @copydoc OptimisedUtil::softwareVertexSkinning
-        virtual void softwareVertexSkinning(
+        virtual void __OGRE_SIMD_ALIGN_ATTRIBUTE softwareVertexSkinning(
             const float *srcPosPtr, float *destPosPtr,
             const float *srcNormPtr, float *destNormPtr,
             const float *blendWeightPtr, const unsigned char* blendIndexPtr,
@@ -96,35 +96,35 @@
             size_t numVertices);
 
         /// @copydoc OptimisedUtil::softwareVertexMorph
-        virtual void softwareVertexMorph(
+        virtual void __OGRE_SIMD_ALIGN_ATTRIBUTE softwareVertexMorph(
             Real t,
             const float *srcPos1, const float *srcPos2,
             float *dstPos,
             size_t numVertices);
 
         /// @copydoc OptimisedUtil::concatenateAffineMatrices
-        virtual void concatenateAffineMatrices(
+        virtual void __OGRE_SIMD_ALIGN_ATTRIBUTE concatenateAffineMatrices(
             const Matrix4& baseMatrix,
             const Matrix4* srcMatrices,
             Matrix4* dstMatrices,
             size_t numMatrices);
 
         /// @copydoc OptimisedUtil::calculateFaceNormals
-        virtual void calculateFaceNormals(
+        virtual void __OGRE_SIMD_ALIGN_ATTRIBUTE calculateFaceNormals(
             const float *positions,
             const EdgeData::Triangle *triangles,
             Vector4 *faceNormals,
             size_t numTriangles);
 
         /// @copydoc OptimisedUtil::calculateLightFacing
-        virtual void calculateLightFacing(
+        virtual void __OGRE_SIMD_ALIGN_ATTRIBUTE calculateLightFacing(
             const Vector4& lightPos,
             const Vector4* faceNormals,
             char* lightFacings,
             size_t numFaces);
 
         /// @copydoc OptimisedUtil::extrudeVertices
-        virtual void extrudeVertices(
+        virtual void __OGRE_SIMD_ALIGN_ATTRIBUTE extrudeVertices(
             const Vector4& lightPos,
             Real extrudeDist,
             const float* srcPositions,
--- a/OgreMain/src/OgreSIMDHelper.h
+++ b/OgreMain/src/OgreSIMDHelper.h
@@ -47,48 +47,18 @@
 // For intel's compiler, simply calling alloca seems to do the right
 // thing. The size of the allocated block seems to be irrelevant.
 #define __OGRE_SIMD_ALIGN_STACK()   _alloca(16)
+#define __OGRE_SIMD_ALIGN_ATTRIBUTE
 
-#elif OGRE_CPU == OGRE_CPU_X86 && OGRE_COMPILER == OGRE_COMPILER_GNUC
-//
-// Horrible hack to align the stack to a 16-bytes boundary for gcc.
-//
-// We assume a gcc version >= 2.95 so that
-// -mpreferred-stack-boundary works.  Otherwise, all bets are
-// off.  However, -mpreferred-stack-boundary does not create a
-// stack alignment, but it only preserves it.  Unfortunately,
-// since Ogre are designed as a flexibility library, user might
-// compile their application with wrong stack alignment, even
-// if user taken care with stack alignment, but many versions
-// of libc on linux call main() with the wrong initial stack
-// alignment the result that the code is now pessimally aligned
-// instead of having a 50% chance of being correct.
-//
-#if OGRE_ARCH_TYPE != OGRE_ARCHITECTURE_64
-
-#define __OGRE_SIMD_ALIGN_STACK()                                   \
-    {                                                               \
-        /* Use alloca to allocate some memory on the stack.  */     \
-        /* This alerts gcc that something funny is going on, */     \
-        /* so that it does not omit the frame pointer etc.   */     \
-        (void)__builtin_alloca(16);                                 \
-        /* Now align the stack pointer */                           \
-        __asm__ __volatile__ ("andl $-16, %esp");                   \
-    }
-
-#else // 64
-#define __OGRE_SIMD_ALIGN_STACK()                                   \
-    {                                                               \
-        /* Use alloca to allocate some memory on the stack.  */     \
-        /* This alerts gcc that something funny is going on, */     \
-        /* so that it does not omit the frame pointer etc.   */     \
-        (void)__builtin_alloca(16);                                 \
-        /* Now align the stack pointer */                           \
-        __asm__ __volatile__ ("andq $-16, %rsp");                   \
-    }
-#endif //64
+#elif OGRE_CPU == OGRE_CPU_X86 && (OGRE_COMPILER == OGRE_COMPILER_GNUC || OGRE_COMPILER == OGRE_COMPILER_CLANG) && (OGRE_ARCH_TYPE != OGRE_ARCHITECTURE_64)
+// mark functions with GCC attribute to force stack alignment to 16 bytes
+#define __OGRE_SIMD_ALIGN_ATTRIBUTE __attribute__((force_align_arg_pointer))
 
 #elif defined(_MSC_VER)
 // Fortunately, MSVC will align the stack automatically
+#define __OGRE_SIMD_ALIGN_ATTRIBUTE
+
+#else
+#define __OGRE_SIMD_ALIGN_ATTRIBUTE
 
 #endif
 

Reply via email to