[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#900445: camlzip version 1.07 needed for zlib >= 1.2.9



Package: libzip-ocaml
Version: 1.06-2+b1

I'd like to request that the Debian package of camlzip (libzip-ocaml)
be updated at least to the latest numbered release, version 1.07. The
reason this is significant is that older versions of camlzip up
through 1.06 will no longer work reliably with recent versions of zlib
(I think 1.2.9 and higher), such as version 1.2.11 now in testing.

The problem can be subtle to reproduce, because it is related to
garbage collection. camlzip versions <= 1.06 allocated a zlib stream
object using OCaml's garbage-collected heap, which means that the
object could be moved around in memory. Though this may have been
contrary to the usual expectations of a C library, it was AFAIK not a
practical problem with older zlib versions. However in more recent
zlib versions, there is a sanity check that asserts that the
back-pointer from the internal state object to the stream object is
consistent with the stream object pointer passed to zlib interface
routines. If the OCaml garbage collector has moved the object, the
back-pointer is not updated because the OCaml GC does not know about
the internal state object. Thus this check will fail, causing the
interface routine to return an error code.

The particular case I care about is a large application that uses
camlzip to write compressed log files. The application works correctly
on older systems, such as Ubuntu 16.04 which has camlzip 1.05 and zlib
1.2.8. It also works correctly when writing a small log file, as does
a small test program, probably since in these small programs no
garbage collection happens while the zlib stream is open. But in the
larger program, in the midst of writing a longer stream of text to a
compressed output stream, the program will die with the following
uncaught exception:

Fatal error: exception Gzip.Error("error during compression")

The zlib error code is not exposed in the Gzip.Error exception
message, but with a debugger I can see that it is Z_STREAM_ERROR,
caused by the failure of the check "s->strm != strm" (i.e.,
"strm->state->strm != strm") in deflateStateCheck.

This class of problems (which also affects decompression in other
programs) is discussed on the upstream Github issue tracker at:

https://github.com/xavierleroy/camlzip/issues/1

The other Github issues from other projects that reference that one
give some indication of how this problem can lead to hard-to-debug
failures in other OCaml-based programs.

The fix is in upstream pull request #2; right after it was merged on
January 23rd, 2017, the version number was incremented to 1.07.

 -- Stephen

-- System Information:
Debian Release: buster/sid
  APT prefers testing-debug
  APT policy: (500, 'testing-debug'), (500, 'oldoldstable'), (500, 'testing')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.16.0-1-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages libzip-ocaml depends on:
ii  libc6                                   2.27-3
ii  ocaml-base-nox [ocaml-base-nox-4.05.0]  4.05.0-10+b1
ii  zlib1g                                  1:1.2.11.dfsg-1


Reply to: