#1149484 snappy-tools: FTBFS: make[1]: *** [GNUmakefile:29: check] Error 1

#1149484#5
Date:
2026-09-29 23:06:59 UTC
From:
To:
Dear maintainer:

During a rebuild of all packages in unstable, this package failed to build.

Below you will find the last part of the build log (probably the most
relevant part, but not necessarily). If required, the full build log
is available here:

https://people.debian.org/~sanvila/build-logs/202609/

About the archive rebuild: The build was made on virtual machines from AWS,
using sbuild and a reduced chroot with only build-essential packages.

If you cannot reproduce the bug please contact me privately, as I
am willing to provide ssh access to a virtual machine where the bug is
fully reproducible.

If this is really a bug in one of the build-depends, please use
reassign and add an affects on src:snappy-tools, so that this is still
visible in the BTS web page for this package.

Thanks.
--------------------------------------------------------------------------------
[...]
make[1]: Entering directory '/<<PKGBUILDDIR>>'
! sed 's/^\.Dd/& February 15, 2024/' snappy.1 | groff -K utf8 -te -mdoc 2>&1 > /dev/null | grep .
./test
./test: /tmp/tmp.hVGev5CZK9/4G+1    compressed (file): cksum 4294967295 0 != 2636691535 201457667
./test: /tmp/tmp.hVGev5CZK9/4G    compressed (file): cksum 4294967295 0 != 3359713396 201457665
make[1]: *** [GNUmakefile:29: check] Error 1
make[1]: Leaving directory '/<<PKGBUILDDIR>>'
dh_auto_test: error: make -j1 check returned exit code 2
make: *** [debian/rules:23: binary] Error 25
dpkg-buildpackage: error: debian/rules binary subprocess failed with exit status 2
--------------------------------------------------------------------------------

#1149484#10
Date:
2026-09-30 17:30:33 UTC
From:
To:
I repro this on sid, this is a regression in 1.3.1 against 1.2.

libsnappy snappy::Compress(), in 1.3.1-1 and onward,
treats files of size 2^32 bytes and larger, as empty:
  ftruncate(source_file, 4 * 1024 * 1024 * 1024ull - 1);  <- works
  ftruncate(source_file, 4 * 1024 * 1024 * 1024ull);      <- doesn't, empty output
  ftruncate(source_file, 4 * 1024 * 1024 * 1024ull + 1);  <- doesn't, empty output

# apt install ./*1.3*.deb
# c++ -O3 repro.cpp -orepro -lsnappy
# ltrace -Coll ./repro
size=4294967296 off=0; read=4294967296; available=4294967296
4G: 4294967296 -> 0 (0.00%)
# cat ll
open64("4G", 0x242, 0666)                                                                                 = 3
ftruncate64(3, 4294967296)                                                                                = 0
close(1)                                                                                                  = 0
open64("4G.s", 0x241, 0666)                                                                               = 1
lseek64(3, 0, SEEK_END)                                                                                   = 4294967296
fprintf(0x7f1cde2b14a0, "size=%ld off=%ld; read=%llu; ava"..., 4294967296, 0, 4294967296)                 = 61
snappy::Compress(snappy::Source*, snappy::Sink*)(0x7ffeee916750, 0x7ffeee916740, 0, 0)                    = 0
fprintf(0x7f1cde2b14a0, "%s: %llu -> %llu (%.2f%%)\n", "4G", 4294967296, 0, 0.000000)                     = 28
snappy::Source::~Source()(0x7ffeee916750, 0x7ffeee916590, 0, 0)                                           = 0x5575d8c55d58
snappy::Sink::~Sink()(0x7ffeee916740, 0x7ffeee916590, 0, 0)                                               = 0x5575d8c55d90
+++ exited (status 0) +++

# apt install ./*1.2.2*.deb
# ltrace -Coll ./repro
size=4294967296 off=0; read=4294967296; available=4294967296
4G: 4294967296 -> 201457665 (4.69%)
# head ll
open64("4G", 0x242, 0666)                                                                                 = 3
ftruncate64(3, 4294967296)                                                                                = 0
close(1)                                                                                                  = 0
open64("4G.s", 0x241, 0666)                                                                               = 1
lseek64(3, 0, SEEK_END)                                                                                   = 4294967296
fprintf(0x7f0af78084a0, "size=%ld off=%ld; read=%llu; ava"..., 4294967296, 0, 4294967296)                 = 61
snappy::Compress(snappy::Source*, snappy::Sink*)(0x7ffca4a5ec90, 0x7ffca4a5ec80, 0, 0 <unfinished ...>
fwrite("", 1, 1, 0x7f0af7808580)                                                                          = 1
pread64(3, "", 65536, 0)                                                                                  = 65536
fwrite("", 1, 3074, 0x7f0af7808580)                                                                       = 3074
pread64(3, "", 65536, 65536)                                                                              = 65536
fwrite("", 1, 3074, 0x7f0af7808580)                                                                       = 3074
pread64(3, "", 65536, 131072)                                                                             = 65536
fwrite("", 1, 3074, 0x7f0af7808580)                                                                       = 3074
pread64(3, "", 65536, 196608)                                                                             = 65536


Reproducer:
-- >8 --
// SPDX-License-Identifier: 0BSD


#include <algorithm>
#include <atomic>
#include <clocale>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <err.h>
#include <fcntl.h>
#include <pthread.h>
#include <snappy-sinksource.h>
#include <snappy.h>
#include <unistd.h>

using namespace std::literals;


namespace {
	static char buf[0xFFFFFF];


	// A Source is an interface that yields a sequence of bytes
	struct fd_source : snappy::Source {
		int fd;
		off_t size, off;

		fd_source(int fd) : fd(fd), off(0) {
			if((this->size = lseek(this->fd, 0, SEEK_END)) == -1)
				this->off = -1;
		}

		// Return the number of bytes left to read from the source
		virtual size_t Available() const { return this->size - this->off; }

		// Peek at the next flat region of the source.  Does not reposition
		// the source.  The returned region is empty iff Available()==0.
		//
		// Returns a pointer to the beginning of the region and store its
		// length in *len.
		//
		// The returned region is valid until the next call to Skip() or
		// until this object is destroyed, whichever occurs first.
		//
		// The returned region may be larger than Available() (for example
		// if this ByteSource is a view on a substring of a larger source).
		// The caller is responsible for ensuring that it only reads the
		// Available() bytes.
		virtual const char * Peek(size_t * len) {
			static_assert(snappy::kBlockSize <= sizeof(buf));
			ssize_t rd;
			while((rd = pread(this->fd, buf, std::min(static_cast<off_t>(snappy::kBlockSize), this->size), this->off)) == -1 && errno == EINTR)
				;
			if(rd == -1)
				err(2, "%s", "4G");
			if(rd == 0)
				this->off = this->size;
			*len = rd;
			return buf;
		}

		// Skip the next n bytes.  Invalidates any buffer returned by
		// a previous call to Peek().
		// REQUIRES: Available() >= n
		virtual void Skip(size_t n) { this->off += n; }
	};

	struct FILE_sink : snappy::Sink {
		FILE * f;

		FILE_sink(FILE * f) : f(f) {}

		// Append "bytes[0,n-1]" to this.
		virtual void Append(const char * bytes, size_t n) {
			if(std::fwrite(bytes, 1, n, this->f) != n)
				err(2, "write error");
		}
	};
}

int main() {
	int source_file = open("4G", O_RDWR | O_CREAT | O_TRUNC, 0666);
	ftruncate(source_file, 4 * 1024 * 1024 * 1024ull);

	close(1);
	open("4G.s", O_WRONLY | O_CREAT | O_TRUNC, 0666);

	FILE_sink sink{stdout};
	fd_source source{source_file};
	unsigned long long read = source.size - source.off;
	std::fprintf(stderr, "size=%ld off=%ld; read=%llu; available=%zu\n", source.size , source.off,  read ,source.Available());
	if(read != source.Available())
		errno = EOVERFLOW, err(2, "%s", "4G");

	unsigned long long written = Compress(&source, &sink);

	std::fprintf(stderr, "%s: %llu -> %llu (%.2f%%)\n", "4G", read, written, 100. * ((double)written / read));
}
-- >8 --

#1149484#27
Date:
2026-10-01 17:26:53 UTC
From:
To:
Control: forwarded -1 https://github.com/google/snappy/issues/266
[...]
[...]
Thanks, unfortunately it affects more projects as well. It was
reported upstream for more than a week. Until now, there has been no
response. :(

Laszlo/GCS

#1149484#34
Date:
2026-10-22 20:44:53 UTC
From:
To:
Dear Maintainer,

I've built the package from the 1.3.1-3 sources, adding
the patch from https://github.com/google/snappy/pull/269/changes

It seems to pass the internal build tests, and the reproducer
from the previous message is also giving reasonable output.

Please consider releasing a version with this patch added.
I am attaching the patch file to make it easy, please
let me know if there's anything else I can do to help.

#1149484#39
Date:
2026-10-23 20:23:47 UTC
From:
To:
We believe that the bug you reported is fixed in the latest version of
snappy, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 1149484@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Laszlo Boszormenyi (GCS) <gcs@debian.org> (supplier of updated snappy package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)
Format: 1.8
Date: Fri, 23 Oct 2026 21:23:07 +0200
Source: snappy
Architecture: source
Version: 1.3.1-4
Distribution: unstable
Urgency: medium
Maintainer: Laszlo Boszormenyi (GCS) <gcs@debian.org>
Changed-By: Laszlo Boszormenyi (GCS) <gcs@debian.org>
Closes: 1149484
Changes:
 snappy (1.3.1-4) unstable; urgency=medium
 .
   * Backport upstream fix to use uint64_t for literal_length to prevent 32-bit
     overflow (closes: #1149484).
Checksums-Sha1:
 33e0a939df691727730e6b91d8d0b78ac7f37f18 1842 snappy_1.3.1-4.dsc
 3220064fbe99fbbb45f2ec6e3b29be4243bfb953 17960 snappy_1.3.1-4.debian.tar.xz
Checksums-Sha256:
 58c61f68bb4eccb4b1868415d0aa240b5c0800078008036b73713f02fa3916b4 1842 snappy_1.3.1-4.dsc
 9c5588bffe08f190978bd983b6e3eab91c99ac61517b98098d147db7a80be8ef 17960 snappy_1.3.1-4.debian.tar.xz
Files:
 2b63513ecd315c4370a0b73cd5df1f68 1842 libs optional snappy_1.3.1-4.dsc
 6edc8537bd36fcc3c0dab78a2b620a84 17960 libs optional snappy_1.3.1-4.debian.tar.xz
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEfYh9yLp7u6e4NeO63OMQ54ZMyL8FAmrbuowACgkQ3OMQ54ZM
yL+/ohAAod/l4W7HRXljdTkr3x0sFfYsQ/j62D9vn8tjzPPAwjTniVrywjRxZ6nG
DqcwgFZp185H3Vyy59+2MP6QqQ82ahmfUAvTFN5CB6c+MRG4gMZ57tRqfaM0BaZO
SgiWPKsjAHyEeEuQK+1m29mzvotw4CxF8pD0qOFI7Tc8V+aB+3mNcXaxndQq9UFr
ZNX3kibsMApzcGPDI5YjqBUXTTK96M8wO5QeViEq2jJsJoKEQVa16Iwo+S3cvARR
Jwn9dRL2HjOcF0iPnFXuuM+AvVTkECAZbcMuD7bSJP7hSNObpQ0vUEsmwmCLlvdg
eZXNeJ0xkoeLjvrtPx2VcczS7l1snOvlZ1kjfI81D2GQySeRZR8P1VdHH7GTjbA3
Lc71S4tF0hisYxhjmkwn463lNJGtQheLj/itW3JFWMnsswCt3Aklak+gO6P6Nnc4
kpPnOXmzZhWiyvmmmVSpkfHFRwbHpApQ13TmmpwZ8UcKaV9nbr/K2W8cD7VlMqPo
xp3M6xgcAbdRckWe8lIFug+FbYnBYKuduE5N/CQhzEqrIONTUfx4YMZBUzgntbw4
YWw0UdP9VsNMKGXHshV5rtRuEt+Q/maW+CzGV08pCwcyljRsQoPDFgy8c/jpbpin
Tc1Lbdj6zDAROwkessOqNjlmfVs68bBEN5nGF3eV9QAhltu7hws=
=pPIE
-----END PGP SIGNATURE-----