debdiff falconpl_0.9.6.9-git20120606-2.dsc falconpl_0.9.6.9-git20120606-2.1.dsc
diff -Nru falconpl-0.9.6.9-git20120606/debian/changelog 
falconpl-0.9.6.9-git20120606/debian/changelog
--- falconpl-0.9.6.9-git20120606/debian/changelog       2012-12-26 
05:43:56.000000000 +0000
+++ falconpl-0.9.6.9-git20120606/debian/changelog       2014-03-26 
13:02:12.000000000 +0000
@@ -1,3 +1,12 @@
+falconpl (0.9.6.9-git20120606-2.1) unstable; urgency=medium
+
+  * Non-maintainer upload.
+  * Fix alignment issue on 32-bit MIPS.
+    Patch by Dejan Latinovic.
+    Closes: #711787
+
+ -- Anibal Monsalve Salazar <ani...@debian.org>  Wed, 26 Mar 2014 13:02:04 
+0000
+
 falconpl (0.9.6.9-git20120606-2) unstable; urgency=medium
 
   * debian/patches/02-Fixed-the-value-set-for-CURLOPT_SSL_VERIFYHOST.patch:
diff -Nru 
falconpl-0.9.6.9-git20120606/debian/patches/03-fix-unaligned-malloc-mips.patch 
falconpl-0.9.6.9-git20120606/debian/patches/03-fix-unaligned-malloc-mips.patch
--- 
falconpl-0.9.6.9-git20120606/debian/patches/03-fix-unaligned-malloc-mips.patch  
    1970-01-01 01:00:00.000000000 +0100
+++ 
falconpl-0.9.6.9-git20120606/debian/patches/03-fix-unaligned-malloc-mips.patch  
    2014-03-26 13:01:10.000000000 +0000
@@ -0,0 +1,110 @@
+From: Dejan Latinovic <dejan.latino...@imgtec.com>
+Subject: falconpl patch
+
+https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=711787
+
+We looked at the falconpl package. As Aurelien Jarno said (see his
+message at the web address below), this is not a lack of memory issue
+but an alignment issue.
+
+https://lists.debian.org/debian-mips/2014/03/msg00005.html
+
+Falcon has it own basic memory manager functions. In these functions,
+during memory allocation, the size of allocated memory is expanded by
+sizeof(size_t) [4 bytes, on 32-bit MIPS], which is used for saving an
+amount of allocated memory.
+
+The first 4 bytes are used to store the amount. Because of that, the
+pointer is offset by these 4 bytes and address of the actual data is
+not aligned by 8.
+
+Bus Error happens for data with an amount of 8 bytes or larger, due to
+usage of 32-bit MIPS instructions ldc1 and sdc1, for double type
+access on address not aligned by 8.
+
+To avoid this behavior we add one more block of 4 bytes
+(sizeof(size_t)) during allocation, to realign the data address.
+
+With these changes we were able to built the falconpl successfully on
+our local MIPS board.
+
+Besides that, we run tests from tests/core/testsuite/. There were no
+fails with a Bus Error. Only one test failed, but the same one failed
+on amd64.
+
+The patch that contains these changes is attached.
+
+The other approach was to use lower optimization flags. Using -O0 flag
+we successfully built the falconpl, as well.
+
+--- a/engine/memory.cpp
++++ b/engine/memory.cpp
+@@ -70,7 +70,11 @@
+ 
+ void * DflAccountMemAlloc( size_t amount )
+ {
++#if defined (__mips__ ) && !defined(__mips64)
++   size_t *ret =  (size_t*) malloc( amount + 2 * sizeof(size_t) );
++#else
+    size_t *ret =  (size_t*) malloc( amount + sizeof(size_t) );
++#endif
+    if ( ret == 0 ) {
+       printf( "Falcon: fatal allocation error when allocating %d bytes\n", 
(int) amount );
+       exit(1);
+@@ -78,7 +82,11 @@
+ 
+    gcMemAccount( amount );
+    *ret = amount;
++#if defined (__mips__ ) && !defined(__mips64)
++   return ret+2;
++#else
+    return ret+1;
++#endif
+ }
+ 
+ 
+@@ -87,8 +95,13 @@
+    if ( mem != 0 )
+    {
+       size_t *smem = (size_t*) mem;
++#if defined (__mips__ ) && !defined(__mips64)
++      gcMemUnaccount( smem[-2] );
++      free( smem-2 );
++#else
+       gcMemUnaccount( smem[-1] );
+       free( smem-1 );
++#endif
+    }
+ }
+ 
+@@ -105,10 +118,18 @@
+ 
+ 
+    size_t *smem = (size_t*) mem;
++#if defined (__mips__ ) && !defined(__mips64)
++   smem-=2;
++#else
+    smem--;
++#endif
+    size_t oldalloc = *smem;
+ 
++#if defined (__mips__ ) && !defined(__mips64)
++   size_t *nsmem = (size_t*) realloc( smem, amount + 2 * sizeof( size_t ) );
++#else
+    size_t *nsmem = (size_t*) realloc( smem, amount + sizeof( size_t ) );
++#endif
+ 
+    if ( nsmem == 0 ) {
+       printf( "Falcon: fatal reallocation error when allocating %d bytes\n", 
(int) amount );
+@@ -121,7 +142,11 @@
+    else
+       gcMemUnaccount( oldalloc - amount );
+ 
++#if defined (__mips__ ) && !defined(__mips64)
++   return nsmem+2;
++#else
+    return nsmem+1;
++#endif
+ }
+ 
+ 
diff -Nru falconpl-0.9.6.9-git20120606/debian/patches/series 
falconpl-0.9.6.9-git20120606/debian/patches/series
--- falconpl-0.9.6.9-git20120606/debian/patches/series  2012-12-26 
05:38:36.000000000 +0000
+++ falconpl-0.9.6.9-git20120606/debian/patches/series  2014-03-26 
12:55:08.000000000 +0000
@@ -1,2 +1,3 @@
 01_gtk_MessageDialog_Wformat-security.patch
 02-Fixed-the-value-set-for-CURLOPT_SSL_VERIFYHOST.patch
+03-fix-unaligned-malloc-mips.patch

Attachment: signature.asc
Description: Digital signature



Reply via email to