Bug#950433: Debdiff fixing linbox FTBFS on armhf and mipsel.
peter green
plugwash at p10link.net
Sat Feb 1 19:17:46 GMT 2020
tags 950433 +patch
tags 944055 +patch
thanks
As has been reported linbox is currently blocked from migrating to testing by build failures on armhf and mipsel autobuilders.
In some armhf environments (notablly on Debian porterboxes and buildds with arm64 kernels), linbox fails to build with bus errors. I tracked these down to dodgy pointer typecasts leading to unaligned memory accesses. I fixed these by replacing the dodgy pointer typecasts with memcpy calls.
The mipsel failues were a case of the assembler running out of memory. I don't quite understand why the assembler is running out of memory so early, maybe it is being run inside the compiler and the compiler has already eaten a bunch of address space. In any case I decided the sensible thing to do was to simply disable the tests in question on mipsel.
While working on these issues I ran into problems with the clean target not cleaning up properly which I also fixed.
Note: the mipsel and arm64 patches were tested seperately, I did not do any test builds with both enabled, but I don't see any reason to expect problems.
A debdiff is attached
-------------- next part --------------
diff -Nru linbox-1.6.3/debian/changelog linbox-1.6.3/debian/changelog
--- linbox-1.6.3/debian/changelog 2019-09-11 18:44:18.000000000 +0000
+++ linbox-1.6.3/debian/changelog 2020-02-01 15:52:03.000000000 +0000
@@ -1,3 +1,14 @@
+linbox (1.6.3-1.1) UNRELEASED; urgency=medium
+
+ * Non-maintainer upload.
+ * Replace dangerous pointer casts that are causing bus errors on
+ some arm setups with memcpy calls.
+ * Disable test-rank-md, test-solve-full and test-solve on mips/mipsel,
+ they fail to build with an out of memory error from the assembler on mipsel.
+ * Fix clean target.
+
+ -- Peter Michael Green <plugwash at debian.org> Sat, 01 Feb 2020 15:52:03 +0000
+
linbox (1.6.3-1) unstable; urgency=medium
* Team upload.
diff -Nru linbox-1.6.3/debian/patches/replace-dangerous-pointer-casts-with-memcpy.patch linbox-1.6.3/debian/patches/replace-dangerous-pointer-casts-with-memcpy.patch
--- linbox-1.6.3/debian/patches/replace-dangerous-pointer-casts-with-memcpy.patch 1970-01-01 00:00:00.000000000 +0000
+++ linbox-1.6.3/debian/patches/replace-dangerous-pointer-casts-with-memcpy.patch 2020-02-01 15:51:51.000000000 +0000
@@ -0,0 +1,138 @@
+Author: Peter Michael Green <plugwash at debian.org>
+Date: Thu Jan 30 22:25:50 2020 +0000
+
+ Use memcpy instead of dangerous casts. This fixes testsuite failures
+ When building on systems that don't support fully support unaligned
+ memory access.
+
+Index: linbox-1.6.3/linbox/util/serialization.inl
+===================================================================
+--- linbox-1.6.3.orig/linbox/util/serialization.inl
++++ linbox-1.6.3/linbox/util/serialization.inl
+@@ -103,7 +103,7 @@ namespace LinBox {
+ inline uint64_t unserialize_raw(T& value, const std::vector<uint8_t>& bytes, uint64_t offset)
+ {
+ auto uValue = &bytes.at(offset);
+- value = *reinterpret_cast<const T*>(uValue);
++ memcpy(&value,uValue,sizeof(T));
+ return sizeof(T);
+ }
+
+@@ -128,7 +128,7 @@ namespace LinBox {
+ inline uint64_t unserialize(int16_t& value, const std::vector<uint8_t>& bytes, uint64_t offset)
+ {
+ auto uValue = &bytes.at(offset);
+- value = *reinterpret_cast<const int16_t*>(uValue);
++ memcpy(&value,uValue,sizeof(int16_t));
+ #if defined(__LINBOX_HAVE_BIG_ENDIAN)
+ value = __builtin_bswap16(value);
+ #endif
+@@ -137,7 +137,7 @@ namespace LinBox {
+ inline uint64_t unserialize(uint16_t& value, const std::vector<uint8_t>& bytes, uint64_t offset)
+ {
+ auto uValue = &bytes.at(offset);
+- value = *reinterpret_cast<const uint16_t*>(uValue);
++ memcpy(&value,uValue,sizeof(uint16_t));
+ #if defined(__LINBOX_HAVE_BIG_ENDIAN)
+ value = __builtin_bswap16(value);
+ #endif
+@@ -147,7 +147,7 @@ namespace LinBox {
+ inline uint64_t unserialize(int32_t& value, const std::vector<uint8_t>& bytes, uint64_t offset)
+ {
+ auto uValue = &bytes.at(offset);
+- value = *reinterpret_cast<const int32_t*>(uValue);
++ memcpy(&value,uValue,sizeof(int32_t));
+ #if defined(__LINBOX_HAVE_BIG_ENDIAN)
+ value = __builtin_bswap32(value);
+ #endif
+@@ -156,7 +156,7 @@ namespace LinBox {
+ inline uint64_t unserialize(uint32_t& value, const std::vector<uint8_t>& bytes, uint64_t offset)
+ {
+ auto uValue = &bytes.at(offset);
+- value = *reinterpret_cast<const uint32_t*>(uValue);
++ memcpy(&value,uValue,sizeof(uint32_t));
+ #if defined(__LINBOX_HAVE_BIG_ENDIAN)
+ value = __builtin_bswap32(value);
+ #endif
+@@ -166,7 +166,7 @@ namespace LinBox {
+ inline uint64_t unserialize(int64_t& value, const std::vector<uint8_t>& bytes, uint64_t offset)
+ {
+ auto uValue = &bytes.at(offset);
+- value = *reinterpret_cast<const int64_t*>(uValue);
++ memcpy(&value,uValue,sizeof(int64_t));
+ #if defined(__LINBOX_HAVE_BIG_ENDIAN)
+ value = __builtin_bswap64(value);
+ #endif
+@@ -175,7 +175,7 @@ namespace LinBox {
+ inline uint64_t unserialize(uint64_t& value, const std::vector<uint8_t>& bytes, uint64_t offset)
+ {
+ auto uValue = &bytes.at(offset);
+- value = *reinterpret_cast<const uint64_t*>(uValue);
++ memcpy(&value,uValue,sizeof(uint64_t));
+ #if defined(__LINBOX_HAVE_BIG_ENDIAN)
+ value = __builtin_bswap64(value);
+ #endif
+Index: linbox-1.6.3/linbox/blackbox/apply.h
+===================================================================
+--- linbox-1.6.3.orig/linbox/blackbox/apply.h
++++ linbox-1.6.3/linbox/blackbox/apply.h
+@@ -220,7 +220,10 @@ namespace LinBox
+ for (size_t j=0;j< maxword;j=j+2){
+ if (!use_neg || j< maxword-1){
+ long long mask = static_cast<long long>(ydbl[j*m+i]);
+- *(reinterpret_cast<long long*>(ptr) ) |= mask;
++ long long tmp;
++ memcpy(&tmp,ptr,sizeof(long long));
++ tmp |= mask;
++ memcpy(ptr,&tmp,sizeof(long long));
+ ptr+=4;
+ }
+ }
+@@ -228,7 +231,10 @@ namespace LinBox
+ for (size_t j=1;j< maxword;j=j+2){
+ if (!use_neg || j< maxword-1){
+ long long mask = static_cast<long long>(ydbl[j*m+i]);
+- *(reinterpret_cast<long long*>(ptr) ) |= mask;
++ long long tmp;
++ memcpy(&tmp,ptr,sizeof(long long));
++ tmp |= mask;
++ memcpy(ptr,&tmp,sizeof(long long));
+ ptr+=4;
+ }
+ }
+@@ -626,7 +632,10 @@ namespace LinBox
+ bitDest += (size_t)rclen*((i % (size_t)rc)*_n+j);
+ long long mask = static_cast<long long>(ctd[j]);
+ bitDest += 2*i;
+- *(reinterpret_cast<long long*>(bitDest) ) |= mask;
++ long long tmp;
++ memcpy(&tmp,bitDest,sizeof(long long));
++ tmp |= mask;
++ memcpy(bitDest,&tmp,sizeof(long long));
+ }
+ }
+ delete[] dx;
+@@ -738,7 +747,10 @@ namespace LinBox
+ unsigned char* BitDest = combined+chunk_byte*k;
+ for (size_t j=k; j< num_chunks; j+=rc){
+ long long mask = static_cast<long long>(ctd[i*num_chunks+j]);
+- *(reinterpret_cast<long long*>(BitDest) ) |= mask;
++ long long tmp;
++ memcpy(&tmp,BitDest,sizeof(long long));
++ tmp |= mask;
++ memcpy(BitDest,&tmp,sizeof(long long));
+ BitDest+=rc*chunk_byte;
+ }
+ Givaro::Protected::importWords(val, (size_t)rclen, -1, 1, 0, 0, combined);
+@@ -978,7 +990,10 @@ namespace LinBox
+ bitDest += (unsigned char)rclen*((i % (size_t)rc)*_m*_k+j);
+ long long mask = static_cast<long long>(ctd[j]);
+ bitDest += 2*i;
+- *(reinterpret_cast<long long*>(bitDest) ) |= mask;
++ long long tmp;
++ memcpy(&tmp,bitDest,sizeof(long long));
++ tmp |= mask;
++ memcpy(bitDest,&tmp,sizeof(long long));
+ }
+ }
+
diff -Nru linbox-1.6.3/debian/patches/series linbox-1.6.3/debian/patches/series
--- linbox-1.6.3/debian/patches/series 2019-09-07 11:26:53.000000000 +0000
+++ linbox-1.6.3/debian/patches/series 2020-02-01 15:13:08.000000000 +0000
@@ -3,3 +3,4 @@
fix-doc-path.patch
fix-RR-RecCounter.patch
pkgconfig.patch
+replace-dangerous-pointer-casts-with-memcpy.patch
diff -Nru linbox-1.6.3/debian/rules linbox-1.6.3/debian/rules
--- linbox-1.6.3/debian/rules 2019-09-07 11:48:12.000000000 +0000
+++ linbox-1.6.3/debian/rules 2020-02-01 15:52:03.000000000 +0000
@@ -18,9 +18,14 @@
# Disable failing test test-charpoly on mips and mipsel.
# See #797167, #856356 and https://github.com/linbox-team/linbox/issues/37
+# also disable test-rank-md, test-solve-full and test-solve, they fail
+# to build with an out of memory error on mipsel
ifneq (,$(filter mips mipsel, $(DEB_HOST_ARCH_CPU)))
override_dh_autoreconf:
sed -e '/\s*test-charpoly\s*\\/d' -i tests/Makefile.am
+ sed -e '/\s*test-rank-md\s*\\/d' -i tests/Makefile.am
+ sed -e '/\s*test-solve-full\s*\\/d' -i tests/Makefile.am
+ sed -e '/\s*test-solve\s*\\/d' -i tests/Makefile.am
dh_autoreconf
endif
@@ -53,5 +58,10 @@
rm -f doc/linbox-*html/COPYING
endif
+override_dh_auto_clean:
+ dh_auto_clean
+ rm -f _configs.sed doc/Doxyfile doc/DoxyfileDev doc/doxy.debug doc/doxydev.debug linbox/config.h tests/temp2
+ sed -i s/1.6.3/1.6.2/ doc/mainpage.doxy
+
%:
dh $@
More information about the debian-science-maintainers
mailing list