Source: mariadb-10.0
Version: 10.0.27-1
Severity: normal
Tags: patch
Control: block -1 by 838557

Hi,

I've managed to go through all the test failures on mips (apart from
one) and fix them. Patches for each issue are attached. This bug depends
on the ENOTEMPTY patch from #838557 being applied first.

I also have a GitHub fork of the Debian packaging here with the patches
included in it:
https://github.com/jcowgill/mariadb-10.0/tree/mips-fixes

mips-groonga-atomic.patch
Link groonga against libatomic as it uses 64-bit atomic operations not
supported on mips without that helper library.

mips-connect-unaligned.patch
This is a rather large patch attempting to fix some unaligned memory
accesses in the CONNECT storage engine which cause bus errors on mips
(and probably other platforms which prohibit unaligned memory access).

mips-machine.patch
Fix the value of DEFAULT_MACHINE on 32-bit mips platforms.

mips-unstable-tests.patch
Remove various tests from mysql-test/unstable-tests which now pass on mips.

debian-mips-unstable-tests.patch
Updates debian/unstable-tests.mips*
I've added the 'connect.mysql_index' test to the mipsel unstable tests.
It seems to fail sporadically on mipsel. It usually takes about 5
retries to fail, but sometimes less. I'm not sure what the cause is here.

Thanks,
James
Description: Ensure groonga is built with libatomic
 MIPS (and possibly other) platforms require linking against libatomic to
 support 64-bit atomic integers. Groonga was failing to do so and all related
 tests were failing with an atomics relocation error on MIPS.
Author: James Cowgill <jcowg...@debian.org>
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/storage/mroonga/vendor/groonga/CMakeLists.txt
+++ b/storage/mroonga/vendor/groonga/CMakeLists.txt
@@ -256,6 +256,8 @@ endmacro()
 include(build/ac_macros/check_headers.m4)
 include(build/ac_macros/check_functions.m4)
 
+ac_check_lib(atomic __atomic_store_8)
+
 ac_check_symbols(fpclassify math.h)
 ac_check_lib(m fpclassify)
 
--- a/storage/mroonga/vendor/groonga/lib/CMakeLists.txt
+++ b/storage/mroonga/vendor/groonga/lib/CMakeLists.txt
@@ -56,6 +56,7 @@ endif()
 set_target_properties(libgroonga PROPERTIES OUTPUT_NAME "groonga")
 
 set(GRN_ALL_LIBRARIES
+    ${ATOMIC_LIBS}
     ${EXECINFO_LIBS}
     ${RT_LIBS}
     ${PTHREAD_LIBS}
Description: Handle unaligned buffers in connect's TYPBLK class
 On MIPS platforms (and probably others) unaligned memory access results in a
 bus error. In the connect storage engine, block data for some data formats is
 stored packed in memory and the TYPBLK class is used to read values from it.
 Since TYPBLK does not have special handling for this packed memory, it can
 quite easily result in unaligned memory accesses.
 .
 The simple way to fix this is to perform all accesses to the main buffer
 through memcpy. With GCC and optimizations turned on, this call to memcpy is
 completely optimized away on architectures where unaligned accesses are ok
 (like x86).
Author: James Cowgill <jcowg...@debian.org>
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
Index: mariadb-10.0-10.0.27/storage/connect/valblk.h
===================================================================
--- mariadb-10.0-10.0.27.orig/storage/connect/valblk.h
+++ mariadb-10.0-10.0.27/storage/connect/valblk.h
@@ -139,6 +139,7 @@ class VALBLK : public BLOCK {
   int     Prec;             // Precision of float values
   }; // end of class VALBLK
 
+
 /***********************************************************************/
 /*  Class TYPBLK: represents a block of typed values.                  */
 /***********************************************************************/
@@ -151,40 +152,40 @@ class TYPBLK : public VALBLK {
   // Implementation
   virtual bool   Init(PGLOBAL g, bool check);
   virtual int    GetVlen(void) {return sizeof(TYPE);}
-  virtual char   GetTinyValue(int n) {return (char)Typp[n];}
-  virtual uchar  GetUTinyValue(int n) {return (uchar)Typp[n];}
-  virtual short  GetShortValue(int n) {return (short)Typp[n];}
-  virtual ushort GetUShortValue(int n) {return (ushort)Typp[n];}
-  virtual int    GetIntValue(int n) {return (int)Typp[n];}
-  virtual uint   GetUIntValue(int n) {return (uint)Typp[n];}
-  virtual longlong GetBigintValue(int n) {return (longlong)Typp[n];}
-  virtual ulonglong GetUBigintValue(int n) {return (ulonglong)Typp[n];}
-  virtual double GetFloatValue(int n) {return (double)Typp[n];}
+  virtual char   GetTinyValue(int n) {return (char)UnalignedRead(n);}
+  virtual uchar  GetUTinyValue(int n) {return (uchar)UnalignedRead(n);}
+  virtual short  GetShortValue(int n) {return (short)UnalignedRead(n);}
+  virtual ushort GetUShortValue(int n) {return (ushort)UnalignedRead(n);}
+  virtual int    GetIntValue(int n) {return (int)UnalignedRead(n);}
+  virtual uint   GetUIntValue(int n) {return (uint)UnalignedRead(n);}
+  virtual longlong GetBigintValue(int n) {return (longlong)UnalignedRead(n);}
+  virtual ulonglong GetUBigintValue(int n) {return (ulonglong)UnalignedRead(n);}
+  virtual double GetFloatValue(int n) {return (double)UnalignedRead(n);}
   virtual char  *GetCharString(char *p, int n);
-  virtual void   Reset(int n) {Typp[n] = 0;}
+  virtual void   Reset(int n) {UnalignedWrite(n, 0);}
 
   // Methods
   using VALBLK::SetValue;
   virtual void   SetValue(PSZ sp, int n);
   virtual void   SetValue(char *sp, uint len, int n);
   virtual void   SetValue(short sval, int n)
-                  {Typp[n] = (TYPE)sval; SetNull(n, false);}
+                  {UnalignedWrite(n, (TYPE)sval); SetNull(n, false);}
   virtual void   SetValue(ushort sval, int n)
-                  {Typp[n] = (TYPE)sval; SetNull(n, false);}
+                  {UnalignedWrite(n, (TYPE)sval); SetNull(n, false);}
   virtual void   SetValue(int lval, int n)
-                  {Typp[n] = (TYPE)lval; SetNull(n, false);}
+                  {UnalignedWrite(n, (TYPE)lval); SetNull(n, false);}
   virtual void   SetValue(uint lval, int n)
-                  {Typp[n] = (TYPE)lval; SetNull(n, false);}
+                  {UnalignedWrite(n, (TYPE)lval); SetNull(n, false);}
   virtual void   SetValue(longlong lval, int n)
-                  {Typp[n] = (TYPE)lval; SetNull(n, false);}
+                  {UnalignedWrite(n, (TYPE)lval); SetNull(n, false);}
   virtual void   SetValue(ulonglong lval, int n)
-                  {Typp[n] = (TYPE)lval; SetNull(n, false);}
+                  {UnalignedWrite(n, (TYPE)lval); SetNull(n, false);}
   virtual void   SetValue(double fval, int n)
-                  {Typp[n] = (TYPE)fval; SetNull(n, false);}
+                  {UnalignedWrite(n, (TYPE)fval); SetNull(n, false);}
   virtual void   SetValue(char cval, int n)
-                  {Typp[n] = (TYPE)cval; SetNull(n, false);}
+                  {UnalignedWrite(n, (TYPE)cval); SetNull(n, false);}
   virtual void   SetValue(uchar cval, int n)
-                  {Typp[n] = (TYPE)cval; SetNull(n, false);}
+                  {UnalignedWrite(n, (TYPE)cval); SetNull(n, false);}
   virtual void   SetValue(PVAL valp, int n);
   virtual void   SetValue(PVBLK pv, int n1, int n2);
   virtual void   SetMin(PVAL valp, int n);
@@ -206,6 +207,17 @@ class TYPBLK : public VALBLK {
   // Members
   TYPE* const &Typp;
   const char  *Fmt;
+
+  // Unaligned access
+  TYPE UnalignedRead(int n) const {
+    TYPE result;
+    memcpy(&result, Typp + n, sizeof(TYPE));
+    return result;
+  }
+
+  void UnalignedWrite(int n, TYPE value) {
+    memcpy(Typp + n, &value, sizeof(TYPE));
+  }
   }; // end of class TYPBLK
 
 /***********************************************************************/
Index: mariadb-10.0-10.0.27/storage/connect/valblk.cpp
===================================================================
--- mariadb-10.0-10.0.27.orig/storage/connect/valblk.cpp
+++ mariadb-10.0-10.0.27/storage/connect/valblk.cpp
@@ -265,14 +265,14 @@ bool TYPBLK<TYPE>::Init(PGLOBAL g, bool
 template <class TYPE>
 char *TYPBLK<TYPE>::GetCharString(char *p, int n)
   {
-  sprintf(p, Fmt, Typp[n]);
+  sprintf(p, Fmt, UnalignedRead(n));
   return p;
   } // end of GetCharString
 
 template <>
 char *TYPBLK<double>::GetCharString(char *p, int n)
   {
-  sprintf(p, Fmt, Prec, Typp[n]);
+  sprintf(p, Fmt, Prec, UnalignedRead(n));
   return p;
   } // end of GetCharString
 
@@ -288,7 +288,7 @@ void TYPBLK<TYPE>::SetValue(PVAL valp, i
   ChkTyp(valp);
 
   if (!(b = valp->IsNull()))
-    Typp[n] = GetTypedValue(valp);
+    UnalignedWrite(n, GetTypedValue(valp));
   else
     Reset(n);
 
@@ -350,9 +350,9 @@ void TYPBLK<TYPE>::SetValue(PSZ p, int n
   ulonglong val = CharToNumber(p, strlen(p), maxval, Unsigned, &minus); 
     
   if (minus && val < maxval)
-    Typp[n] = (TYPE)(-(signed)val);
+    UnalignedWrite(n, (TYPE)(-(signed)val));
   else
-    Typp[n] = (TYPE)val;
+    UnalignedWrite(n, (TYPE)val);
 
   SetNull(n, false);
   } // end of SetValue
@@ -395,7 +395,7 @@ void TYPBLK<double>::SetValue(PSZ p, int
     longjmp(g->jumper[g->jump_level], Type);
     } // endif Check
 
-  Typp[n] = atof(p);
+  UnalignedWrite(n, atof(p));
   SetNull(n, false);
   } // end of SetValue
 
@@ -427,7 +427,7 @@ void TYPBLK<TYPE>::SetValue(PVBLK pv, in
   ChkTyp(pv);
 
   if (!(b = pv->IsNull(n2) && Nullable))
-    Typp[n1] = GetTypedValue(pv, n2);
+    UnalignedWrite(n1, GetTypedValue(pv, n2));
   else
     Reset(n1);
 
@@ -478,10 +478,10 @@ void TYPBLK<TYPE>::SetMin(PVAL valp, int
   {
   CheckParms(valp, n)
   TYPE  tval = GetTypedValue(valp);
-  TYPE& tmin = Typp[n];
+  TYPE  tmin = UnalignedRead(n);
 
   if (tval < tmin)
-    tmin = tval;
+    UnalignedWrite(n, tval);
 
   } // end of SetMin
 
@@ -493,10 +493,10 @@ void TYPBLK<TYPE>::SetMax(PVAL valp, int
   {
   CheckParms(valp, n)
   TYPE  tval = GetTypedValue(valp);
-  TYPE& tmin = Typp[n];
+  TYPE  tmin = UnalignedRead(n);
 
   if (tval > tmin)
-    tmin = tval;
+    UnalignedWrite(n, tval);
 
   } // end of SetMax
 
@@ -522,7 +522,7 @@ void TYPBLK<TYPE>::SetValues(PVBLK pv, i
 template <class TYPE>
 void TYPBLK<TYPE>::Move(int i, int j)
   {
-  Typp[j] = Typp[i];
+  UnalignedWrite(j, UnalignedRead(i));
   MoveNull(i, j);
   } // end of Move
 
@@ -536,7 +536,7 @@ int TYPBLK<TYPE>::CompVal(PVAL vp, int n
   ChkIndx(n);
   ChkTyp(vp);
 #endif   // _DEBUG
-  TYPE mlv = Typp[n];
+  TYPE mlv = UnalignedRead(n);
   TYPE vlv = GetTypedValue(vp);
 
   return (vlv > mlv) ? 1 : (vlv < mlv) ? (-1) : 0;
@@ -548,8 +548,8 @@ int TYPBLK<TYPE>::CompVal(PVAL vp, int n
 template <class TYPE>
 int TYPBLK<TYPE>::CompVal(int i1, int i2)
   {
-  TYPE lv1 = Typp[i1];
-  TYPE lv2 = Typp[i2];
+  TYPE lv1 = UnalignedRead(i1);
+  TYPE lv2 = UnalignedRead(i2);
 
   return (lv1 > lv2) ? 1 : (lv1 < lv2) ? (-1) : 0;
   } // end of CompVal
@@ -586,7 +586,7 @@ int TYPBLK<TYPE>::Find(PVAL vp)
   TYPE n = GetTypedValue(vp);
 
   for (i = 0; i < Nval; i++)
-    if (n == Typp[i])
+    if (n == UnalignedRead(i))
       break;
 
   return (i < Nval) ? i : (-1);
@@ -602,7 +602,7 @@ int TYPBLK<TYPE>::GetMaxLength(void)
   int i, n, m;
 
   for (i = n = 0; i < Nval; i++) {
-    m = sprintf(buf, Fmt, Typp[i]);
+    m = sprintf(buf, Fmt, UnalignedRead(i));
     n = MY_MAX(n, m);
     } // endfor i
 
@@ -1332,7 +1332,7 @@ char *DATBLK::GetCharString(char *p, int
   char *vp;
 
   if (Dvalp) {
-    Dvalp->SetValue(Typp[n]);
+    Dvalp->SetValue(UnalignedRead(n));
     vp = Dvalp->GetCharString(p);
   } else
     vp = TYPBLK<int>::GetCharString(p, n);
@@ -1348,7 +1348,7 @@ void DATBLK::SetValue(PSZ p, int n)
   if (Dvalp) {
     // Decode the string according to format
     Dvalp->SetValue_psz(p);
-    Typp[n] = Dvalp->GetIntValue();
+    UnalignedWrite(n, Dvalp->GetIntValue());
   } else
     TYPBLK<int>::SetValue(p, n);
 
Description: Fix DEFAULT_MACHINE on mips
 The DEFAULT_MACHINE constant is calculated from the CMAKE_SYSTEM_PROCESSOR
 variable which contains the processor which built mariadb. Since most Debian
 buildds run on 64-bit hardware even though they build 32-bit binaries,
 DEFAULT_MACHINE previously contained "mips64" on 32-bit builds. This confuses
 some mroonga tests which rely on DEFAULT_MACHINE to detect 64-bitness.
 .
 This patch fixes the value of DEFAULT_MACHINE so it always contains just "mips"
 on 32-bit mips builds.
Author: James Cowgill <jcowg...@debian.org>
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/cmake/package_name.cmake
+++ b/cmake/package_name.cmake
@@ -30,6 +30,10 @@ IF(NOT VERSION)
       SET(64BIT 1)
     ENDIF()
 
+    IF(NOT 64BIT AND CMAKE_SYSTEM_PROCESSOR MATCHES "^mips64")
+      SET(DEFAULT_MACHINE "mips")
+    ENDIF()
+
     IF(CMAKE_SYSTEM_NAME MATCHES "Windows")
       SET(NEED_DASH_BETWEEN_PLATFORM_AND_MACHINE 0)
       SET(DEFAULT_PLATFORM "win")
Description: Remove various tests from unstable-tests which now pass on MIPS
Author: James Cowgill <jcowg...@debian.org>
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/mysql-test/unstable-tests
+++ b/mysql-test/unstable-tests
@@ -98,9 +98,8 @@ connect.jdbc-postgresql : New test, adde
 #----------------------------------------------------------------
 
 federated.federatedx             : MDEV-10617 - Wrong checksum, timeouts
-federated.federated_innodb       : MDEV-10617, MDEV-10417 - Wrong checksum, timeouts, fails on Mips
-federated.federated_partition    : MDEV-10417 - Fails on Mips
-federated.federated_transactions : MDEV-10617, MDEV-10417 - Wrong checksum, timeouts, fails on Mips
+federated.federated_innodb       : MDEV-10617 - Wrong checksum, timeouts
+federated.federated_transactions : MDEV-10617 - Wrong checksum, timeouts
 
 #----------------------------------------------------------------
 
@@ -130,8 +129,7 @@ mroonga/storage.index_multiple_column_un
 
 #----------------------------------------------------------------
 
-multi_source.gtid        : MDEV-10620, MDEV-10417 - Timeout in wait condition, fails on Mips
-multi_source.multisource : MDEV-10417 - Fails on Mips
+multi_source.gtid        : MDEV-10620 - Timeout in wait condition
 multi_source.simple      : MDEV-4633 - Wrong slave status output
 multi_source.status_vars : MDEV-4632 - failed while waiting for Slave_received_heartbeats
 
@@ -170,27 +168,21 @@ roles.set_role-9614
 #----------------------------------------------------------------
 
 rpl.last_insert_id                    : MDEV-10625 - warnings in error log
-rpl.rpl_auto_increment                : MDEV-10417 - Fails on Mips
-rpl.rpl_auto_increment_bug45679       : MDEV-10417 - Fails on Mips
 rpl.rpl_auto_increment_update_failure : MDEV-10625 - warnings in error log
 rpl.rpl_binlog_index                  : MDEV-9501 - Warning: failed registering on master
 rpl.rpl_checksum_cache                : MDEV-10626 - Testcase timeout
 rpl.rpl_circular_for_4_hosts          : MDEV-10627 - Testcase timeout
-rpl.rpl_ddl                           : MDEV-10417 - Fails on Mips
 rpl.rpl_gtid_crash                    : MDEV-9501 - Warning: failed registering on master
 rpl.rpl_gtid_master_promote           : MDEV-10628 - Timeout in sync_with_master
 rpl.rpl_gtid_stop_start               : MDEV-10629 - Crash on shutdown
 rpl.rpl_gtid_until                    : MDEV-10625 - warnings in error log
 rpl.rpl_ignore_table                  : Modified on 2016-06-22
-rpl.rpl_innodb_bug30888               : MDEV-10417 - Fails on Mips
 rpl.rpl_insert                        : MDEV-9329 - Fails on Ubuntu/s390x
 rpl.rpl_insert_delayed                : MDEV-9329 - Fails on Ubuntu/s390x
-rpl.rpl_invoked_features              : MDEV-10417 - Fails on Mips
-rpl.rpl_mdev6020                      : MDEV-10630, MDEV-10417 - Timeouts, fails on Mips
+rpl.rpl_mdev6020                      : MDEV-10630 - Timeouts
 rpl.rpl_mdev6386                      : MDEV-10631 - Wrong result on slave
 rpl.rpl_parallel                      : MDEV-10632, MDEV-10653 - Failures to sync, timeouts
 rpl.rpl_parallel_temptable            : MDEV-10356 - Crash in close_thread_tables
-rpl.rpl_partition_innodb              : MDEV-10417 - Fails on Mips
 rpl.rpl_row_drop_create_temp_table    : MDEV-10626 - Testcase timeout
 rpl.rpl_row_sp001                     : MDEV-9329 - Fails on Ubuntu/s390x
 rpl.rpl_semi_sync_uninstall_plugin    : MDEV-7140 - Wrong plugin status
commit 55bada8e1bb704b832a3874e3b27eb728041d934
Author: James Cowgill <jcowg...@debian.org>
Date:   Wed Sep 21 14:35:16 2016 +0100

    Update debian/unstable-tests.mips*

diff --git a/debian/unstable-tests.mips b/debian/unstable-tests.mips
deleted file mode 100644
index b0ba37c..0000000
--- a/debian/unstable-tests.mips
+++ /dev/null
@@ -1,7 +0,0 @@
-federated.federated_partition : https://jira.mariadb.org/browse/MDEV-8691
-federated.federated_transactions : MDEV-8691
-federated.federated_innodb : MDEV-8691
-multi_source.gtid : MDEV-8691
-multi_source.multisource : MDEV-8691
-rpl.rpl_auto_increment : MDEV-8691
-rpl.rpl_invoked_features : MDEV-8691
diff --git a/debian/unstable-tests.mips64el b/debian/unstable-tests.mips64el
deleted file mode 100644
index a9e0ced..0000000
--- a/debian/unstable-tests.mips64el
+++ /dev/null
@@ -1,7 +0,0 @@
-federated.federated_partition : https://jira.mariadb.org/browse/MDEV-8691
-federated.federated_transactions : MDEV-8691
-federated.federated_innodb : MDEV-8691
-multi_source.gtid : MDEV-8691
-multi_source.multisource : MDEV-8691
-rpl.rpl_auto_increment : MDEV-8691
-rpl.rpl_auto_increment_bug45679 : MDEV-8691
diff --git a/debian/unstable-tests.mipsel b/debian/unstable-tests.mipsel
index b0ba37c..770f6b7 100644
--- a/debian/unstable-tests.mipsel
+++ b/debian/unstable-tests.mipsel
@@ -1,7 +1 @@
-federated.federated_partition : https://jira.mariadb.org/browse/MDEV-8691
-federated.federated_transactions : MDEV-8691
-federated.federated_innodb : MDEV-8691
-multi_source.gtid : MDEV-8691
-multi_source.multisource : MDEV-8691
-rpl.rpl_auto_increment : MDEV-8691
-rpl.rpl_invoked_features : MDEV-8691
+connect.mysql_index : Fails sporadically on mipsel

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to