OCaml and LZMA - decompression based on xz-utils and 7zip

Recently I needed to process a bunch of data that can be valid LZMA stream, can be invalid (e.g. damaged) LZMA stream, or just can look like it. I searched pure OCaml implementations and found none. Then I found the old library, but after a while decided to implement my own bindings. At first I tried to use liblzma from xz-utils, and created Ctypes-based bindings. But after working with them I found out that xz-utils implementation is not thread-safe, thus causing a heap corruption/segfaults when ran in many threads. So I switched to 7zip implementation of LZMA algorithm, and implemented bindings around them ocaml-lzma_7z.

Feel free to reuse the code any way you like, or complain in issues (or even send pull requests).

2 Likes