Package: snappy
Version: 1.1.4-2
Severity: serious
Tags: patch
User: [email protected]
Usertags: origin-ubuntu artful ubuntu-patch

Hi Laszlo,

The snappy 1.1.4 release tarball as distributed by upstream does not match
its git tag; it contains an additional patch of unclear origin which is
broken on armhf (as confirmed on harris.d.o).

In addition, the breakage would have been caught by the upstream test suite
at package build time, except the 'make check' line is commented out in
debian/rules.  Since this was commented out, this was only caught because it
causes a build failure of pytables in Ubuntu, which is two steps removed
from snappy itself.

Attached is a patch, which I've applied in Ubuntu, to address both of these
issues.  I have also written to upstream about the issue of the wrong
tarball.

It might be more appropriate to address the missing 'make check' issue by
instead migrating debian/rules to pure dh(1), but I would leave that to you
as maintainer to decide.

Cheers,
-- 
Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
Ubuntu Developer                                    http://www.debian.org/
[email protected]                                     [email protected]
diff -Nru snappy-1.1.4/debian/patches/pristine-upstream.patch 
snappy-1.1.4/debian/patches/pristine-upstream.patch
--- snappy-1.1.4/debian/patches/pristine-upstream.patch 1969-12-31 
16:00:00.000000000 -0800
+++ snappy-1.1.4/debian/patches/pristine-upstream.patch 2017-06-27 
20:51:09.000000000 -0700
@@ -0,0 +1,65 @@
+Description: use pristine upstream git source that works on armhf
+ The upstream release tarball for 1.1.4 includes a change that is not
+ documented at all in the git history, and is definitely not present in the
+ tag for 1.1.4.  It also introduces a change that makes snappy not work
+ correctly on armhf.  Patch this out so that our source matches the upstream
+ tag.
+Author: unknown
+Last-Modified: 2017-06-27
+Forwarded: not-needed
+
+--- snappy-1.1.4/snappy.cc     1980-01-01 08:00:00.000000000 +0000
++++ snappy/snappy.cc   2017-06-28 03:33:33.557981656 +0000
+@@ -36,7 +36,6 @@
+ #include <stdio.h>
+ 
+ #include <algorithm>
+-#include <limits>
+ #include <string>
+ #include <vector>
+ 
+@@ -317,22 +316,29 @@
+ 
+ namespace internal {
+ uint16* WorkingMemory::GetHashTable(size_t input_size, int* table_size) {
+-  if (input_size > kMaxHashTableSize) {
+-    *table_size = kMaxHashTableSize;
+-  } else if (input_size < 256) {
+-    *table_size = 256;
++  // Use smaller hash table when input.size() is smaller, since we
++  // fill the table, incurring O(hash table size) overhead for
++  // compression, and if the input is short, we won't need that
++  // many hash table entries anyway.
++  assert(kMaxHashTableSize >= 256);
++  size_t htsize = 256;
++  while (htsize < kMaxHashTableSize && htsize < input_size) {
++    htsize <<= 1;
++  }
++
++  uint16* table;
++  if (htsize <= ARRAYSIZE(small_table_)) {
++    table = small_table_;
+   } else {
+-    // Since table size must be a power of 2, round up to the next power of 2.
+-    *table_size = 1 << (std::numeric_limits<size_t>::digits -
+-                        __builtin_clzll(input_size - 1));
+-  }
+-  if (*table_size <= ARRAYSIZE(small_table_)) {
+-    memset(small_table_, 0, 2 * *table_size);
+-    return small_table_;
+-  }
+-  if (!large_table_) large_table_ = new uint16[kMaxHashTableSize];
+-  memset(large_table_, 0, 2 * *table_size);
+-  return large_table_;
++    if (large_table_ == NULL) {
++      large_table_ = new uint16[kMaxHashTableSize];
++    }
++    table = large_table_;
++  }
++
++  *table_size = htsize;
++  memset(table, 0, htsize * sizeof(*table));
++  return table;
+ }
+ }  // end namespace internal
+ 
diff -Nru snappy-1.1.4/debian/patches/series snappy-1.1.4/debian/patches/series
--- snappy-1.1.4/debian/patches/series  1969-12-31 16:00:00.000000000 -0800
+++ snappy-1.1.4/debian/patches/series  2017-06-27 20:51:27.000000000 -0700
@@ -0,0 +1 @@
+pristine-upstream.patch
diff -Nru snappy-1.1.4/debian/rules snappy-1.1.4/debian/rules
--- snappy-1.1.4/debian/rules   2016-03-19 06:24:58.000000000 -0700
+++ snappy-1.1.4/debian/rules   2017-06-27 20:51:27.000000000 -0700
@@ -26,7 +26,7 @@
        ./configure $(CROSS) --prefix=/usr --mandir=\$${prefix}/share/man 
--infodir=\$${prefix}/share/info --libdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH)
        $(MAKE)
 ifeq "$(filter nocheck,$(DEB_BUILD_OPTIONS))" ""
-#      $(MAKE) check
+       $(MAKE) check
 endif
        
        # Create a create a "convenience library" which is static, but suitable 
for linking

Reply via email to