Control: reassign -1 src:snappy 1.2.0-2
Control: merge 1070785 -1

On Fri, May 17, 2024 at 10:41:58PM +0200, Santiago Vila wrote:
> Package: src:snappy-tools
> Version: 1-1
> Severity: serious
> Tags: ftbfs
> 
> Dear maintainer:
> 
> During a rebuild of all packages in unstable, your package failed to build:
> 
> --------------------------------------------------------------------------------
> snappy.cpp: In function ‘int main(int, char* const*)’:
> snappy.cpp:575:51: error: call of overloaded 
> ‘Compress({anonymous}::fd_source*, {anonymous}::FILE_sink*)’ is ambiguous
>   575 |                                 written = Compress(&source, &sink);
>       |                                           ~~~~~~~~^~~~~~~~~~~~~~~~
> In file included from snappy.cpp:14:
> /usr/include/snappy.h:81:10: note: candidate: ‘size_t 
> snappy::Compress(Source*, Sink*)’
>    81 |   size_t Compress(Source* reader, Sink* writer);
>       |          ^~~~~~~~
> /usr/include/snappy.h:82:10: note: candidate: ‘size_t 
> snappy::Compress(Source*, Sink*, CompressionOptions)’
>    82 |   size_t Compress(Source* reader, Sink* writer,
>       |          ^~~~~~~~

Not our bug:
this is #1070785, caused by a breaking fix to #1070217,
and now subject to a potential src:snappy transition in #1070977.

When tchet@ brought the latter to my attention I build-tested against
unbroken libsnappy-dev 1.2.0-3 from experimental and that worked,
so if that ever happens snappy-tools will work.

But a fixed patch, would be much easier to produce:
in restore-api.patch in 1.2.0-2 I see
        --- snappy-1.2.0.orig/snappy.h
        +++ snappy-1.2.0/snappy.h
        @@ -78,6 +78,7 @@ namespace snappy {
        
           // Compress the bytes read from "*reader" and append to "*writer". 
Return the
           // number of bytes written.
        +  size_t Compress(Source* reader, Sink* writer);
           size_t Compress(Source* reader, Sink* writer,
                           CompressionOptions options = {});
which will be trivially fixed by deleting the "= {}"
(thus, only the two-argument Compress will be considered when two
 arguments are given, like in snappy-tools and ceph;
 the signatures are not affected by this, since defaults are call-site-only).

I also see
        @@ -157,6 +158,8 @@ namespace snappy {
           // `uncompressed_length` is the total number of bytes to be read 
from the
           // elements of `iov` (_not_ the number of elements in `iov`).
           void RawCompressFromIOVec(const struct iovec* iov, size_t 
uncompressed_length,
        +                            char* compressed, size_t* 
compressed_length);
        +  void RawCompressFromIOVec(const struct iovec* iov, size_t 
uncompressed_length,
                                     char* compressed, size_t* 
compressed_length,
                                     CompressionOptions options = {});
which should've gotten a similar treatment,
or actually no treatment at all, because RawCompressFromIOVec() is new in 1.2
(but AFAICT calling RawCompressFromIOVec() will fail on overload resolution 
like Compress()).

László: I'm attaching a replacement restore-api.patch for src:snappy (based on 
1.2.0-1).
This provides the same symbols as 1.1.9-3 + the new API, seamlessly,
which I think is what you were indending with your original patch in 1.2.0-2:
        $ diff -U0 <(nm -D /lib/x86_64-linux-gnu/libsnappy.so.1 | cut -d\  -f2- 
| sort) <(nm -D sn/usr/lib/x86_64-linux-gnu/libsnappy.so.1 | cut -d\  -f2- | 
sort)
        --- /dev/fd/63  2024-05-18 00:17:19.586857117 +0200
        +++ /dev/fd/62  2024-05-18 00:17:19.590857295 +0200
        @@ -8,0 +9,3 @@
        +T _ZN6snappy11RawCompressEPKcmPcPmNS_18CompressionOptionsE
        +T _ZN6snappy12DeferMemCopyEPPKvPmS1_m
        +T _ZN6snappy13ClearDeferredEPPKvPmPh
        @@ -15,0 +19 @@
        +T 
_ZN6snappy17CompressFromIOVecEPK5iovecmPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEENS_18CompressionOptionsE
        @@ -18,0 +23,2 @@
        +T _ZN6snappy20RawCompressFromIOVecEPK5iovecmPcPm
        +T 
_ZN6snappy20RawCompressFromIOVecEPK5iovecmPcPmNS_18CompressionOptionsE
        @@ -42,4 +47,0 @@
        -T _ZN6snappy7MemCopyElPKhm
        -T _ZN6snappy7MemCopyEPcPKhm
        -T _ZN6snappy7MemMoveElPKvm
        -T _ZN6snappy7MemMoveEPcPKvm
        @@ -46,0 +49 @@
        +T 
_ZN6snappy8CompressEPKcmPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEENS_18CompressionOptionsE
        @@ -47,0 +51 @@
        +T _ZN6snappy8CompressEPNS_6SourceEPNS_4SinkENS_18CompressionOptionsE
        @@ -52,0 +57,3 @@
        +T _ZN6snappy8internal26CompressFragmentDoubleHashEPKcmPcPtiS4_i
        +T _ZN6snappy9MemCopy64ElPKvm
        +T _ZN6snappy9MemCopy64EPcPKvm
        @@ -62 +69 @@
        -                U _ZdlPv@GLIBCXX_3.4
        +                U _ZdlPvm@CXXABI_1.3.9
        @@ -68,0 +76 @@
        +                U _ZSt24__throw_out_of_range_fmtPKcz@GLIBCXX_3.4.20
        @@ -71,0 +80 @@
        +V _ZTIN6snappy17SnappyIOVecReaderE
        @@ -75,0 +85 @@
        +V _ZTSN6snappy17SnappyIOVecReaderE
        @@ -79,0 +90 @@
        +V _ZTVN6snappy17SnappyIOVecReaderE
        @@ -87,0 +99,5 @@
        +W _ZN6snappy17SnappyIOVecReader4PeekEPm
        +W _ZN6snappy17SnappyIOVecReader4SkipEm
        +W _ZN6snappy17SnappyIOVecReaderD0Ev
        +W _ZN6snappy17SnappyIOVecReaderD1Ev
        +W _ZN6snappy17SnappyIOVecReaderD2Ev
        @@ -96,0 +113 @@
        +W _ZNK6snappy17SnappyIOVecReader9AvailableEv

I have tested this briefly and it works with snappy-tools built for
snappy 1.1.9 (bookworm), and src:snappy-tools builds against it.
Maybe a migration is unnecessary?

Best,
Description: release 1.2.0 added CompressionOptions without backward compatibilty
 Add API calls without CompressionOptions which calls the new functions with
 empty options.
Author: наб <nabijaczlew...@nabijaczleweli.xyz>
Bug-Debian: https://bugs.debian.org/1070217
Forwarded: no
Last-Update: 2024-05-18

--- snappy-1.2.0.orig/snappy.cc
+++ snappy-1.2.0/snappy.cc
@@ -1792,6 +1792,10 @@ bool GetUncompressedLength(Source* sourc
   return decompressor.ReadUncompressedLength(result);
 }
 
+size_t Compress(Source* reader, Sink* writer) {
+  return Compress(reader, writer, {});
+}
+
 size_t Compress(Source* reader, Sink* writer, CompressionOptions options) {
   assert(options.level == 1 || options.level == 2);
   int token = 0;
@@ -2299,6 +2303,11 @@ bool IsValidCompressed(Source* compresse
 }
 
 void RawCompress(const char* input, size_t input_length, char* compressed,
+                 size_t* compressed_length) {
+  RawCompress(input, input_length, compressed, compressed_length, {});
+}
+
+void RawCompress(const char* input, size_t input_length, char* compressed,
                  size_t* compressed_length, CompressionOptions options) {
   ByteArraySource reader(input, input_length);
   UncheckedByteArraySink writer(compressed);
@@ -2309,6 +2318,11 @@ void RawCompress(const char* input, size
 }
 
 void RawCompressFromIOVec(const struct iovec* iov, size_t uncompressed_length,
+                          char* compressed, size_t* compressed_length) {
+  return RawCompressFromIOVec(iov, uncompressed_length, compressed, compressed_length, {});
+}
+
+void RawCompressFromIOVec(const struct iovec* iov, size_t uncompressed_length,
                           char* compressed, size_t* compressed_length,
                           CompressionOptions options) {
   SnappyIOVecReader reader(iov, uncompressed_length);
@@ -2319,6 +2333,11 @@ void RawCompressFromIOVec(const struct i
   *compressed_length = writer.CurrentDestination() - compressed;
 }
 
+size_t Compress(const char* input, size_t input_length,
+                std::string* compressed) {
+  return Compress(input, input_length, compressed, {});
+}
+
 size_t Compress(const char* input, size_t input_length, std::string* compressed,
                 CompressionOptions options) {
   // Pre-grow the buffer to the max length of the compressed output
--- snappy-1.2.0.orig/snappy.h
+++ snappy-1.2.0/snappy.h
@@ -78,8 +78,9 @@ namespace snappy {
 
   // Compress the bytes read from "*reader" and append to "*writer". Return the
   // number of bytes written.
+  size_t Compress(Source* reader, Sink* writer);
   size_t Compress(Source* reader, Sink* writer,
-                  CompressionOptions options = {});
+                  CompressionOptions options);
 
   // Find the uncompressed length of the given stream, as given by the header.
   // Note that the true length could deviate from this; the stream could e.g.
@@ -99,7 +100,9 @@ namespace snappy {
   //
   // REQUIRES: "input[]" is not an alias of "*compressed".
   size_t Compress(const char* input, size_t input_length,
-                  std::string* compressed, CompressionOptions options = {});
+                  std::string* compressed);
+  size_t Compress(const char* input, size_t input_length,
+                  std::string* compressed, CompressionOptions options);
 
   // Same as `Compress` above but taking an `iovec` array as input. Note that
   // this function preprocesses the inputs to compute the sum of
@@ -151,7 +154,9 @@ namespace snappy {
   //    ... Process(output, output_length) ...
   //    delete [] output;
   void RawCompress(const char* input, size_t input_length, char* compressed,
-                   size_t* compressed_length, CompressionOptions options = {});
+                   size_t* compressed_length);
+  void RawCompress(const char* input, size_t input_length, char* compressed,
+                   size_t* compressed_length, CompressionOptions options);
 
   // Same as `RawCompress` above but taking an `iovec` array as input. Note that
   // `uncompressed_length` is the total number of bytes to be read from the

Attachment: signature.asc
Description: PGP signature

Reply via email to