Package: src:golang-github-peterbourgon-diskv
Version: 3.0.0-2
Severity: normal
Tags: patch upstream
User: [email protected]
Usertags: origin-ubuntu ubuntu-patch stonking
X-Debbugs-Cc: [email protected]
Dear Maintainer,
In Ubuntu we hit an FTBFS of golang-github-peterbourgon-diskv when the
package is built with Go 1.27:
The compression tests fill a 4 KiB buffer with random bytes in {a-z}
(seeded from the clock) and assert that every flate level shrinks it.
Random data over 26 symbols has no LZ77 back-references, and Go 1.27's
fast flate encoders (levels 1-8) now emit stored (uncompressed) blocks
in that case, so the compressed output can be >= the input and the test
fails non-deterministically.
The attached patch (debian/patches/go1.27-compressible-data.patch)
replaces the payload with deterministic runs of repeated bytes, which
compress reliably at every flate level while still exercising the
compress/decompress round-trip. With Go 1.27 the gzip/deflate
compression tests pass consistently (verified over repeated runs).
The fix has also been forwarded upstream:
https://github.com/peterbourgon/diskv/pull/80
Ubuntu bug for reference:
https://bugs.launchpad.net/bugs/2164597
Thanks for considering.
--
Anshul Singh
Description: Use deterministic compressible test data for Go 1.27
The compression tests filled a 4 KiB buffer with random bytes in {a-z} and
asserted that every flate level shrank it. Random data over 26 symbols has no
LZ77 back-references, and Go 1.27's fast flate encoders (levels 1-8) now emit
stored (uncompressed) blocks in that case, so the output could equal or exceed
the input and the test failed non-deterministically (it also depended on a
clock-seeded PRNG). Replace the payload with deterministic runs of repeated
bytes, which compress reliably at every level while still exercising the
compress/decompress round-trip.
Author: Anshul Singh <[email protected]>
Origin: https://github.com/peterbourgon/diskv/pull/80
Bug-Ubuntu: https://bugs.launchpad.net/bugs/2164597
Forwarded: https://github.com/peterbourgon/diskv/pull/80
Last-Update: 2026-09-23
Index: golang-github-peterbourgon-diskv-3.0.0/compression_test.go
===================================================================
--- golang-github-peterbourgon-diskv-3.0.0.orig/compression_test.go 2026-07-28 21:37:42.000000000 +0900
+++ golang-github-peterbourgon-diskv-3.0.0/compression_test.go 2026-07-28 22:26:54.703198803 +0900
@@ -3,16 +3,10 @@
import (
"compress/flate"
"fmt"
- "math/rand"
"os"
"testing"
- "time"
)
-func init() {
- rand.Seed(time.Now().UnixNano())
-}
-
func testCompressionWith(t *testing.T, c Compression, name string) {
d := New(Options{
BasePath: "compression-test",
@@ -24,7 +18,12 @@
sz := 4096
val := make([]byte, sz)
for i := 0; i < sz; i++ {
- val[i] = byte('a' + rand.Intn(26)) // {a-z}; should compress some
+ // Deterministic, LZ77-compressible payload (runs of repeated bytes).
+ // Go 1.27's fast flate encoders (levels 1-8) emit stored, uncompressed
+ // blocks when a block has no back-references, so the previous random
+ // {a-z} data would (non-deterministically) fail to shrink at those
+ // levels. Repeated runs compress reliably at every level.
+ val[i] = byte('a' + (i/16)%26)
}
key := "a"