xvilka / ocaml-lzma Goto Github PK
View Code? Open in Web Editor NEWBindings to xz-utils (liblzma)
License: The Unlicense
Bindings to xz-utils (liblzma)
License: The Unlicense
Since xz-util is not thread-safe it is common that it segfaults when you performing deinitialization of LZMA state in multiple threads. See this piece of the code:
let lzma_deinit streampp =
(* Nullify the "next_in" pointer, stupid LZMA lib
* for some reason set it in a wrong value, sigh *)
let stream = (!@ (!@ streampp)) in
(*setf stream stream_next_in (from_voidp uint8_t null); *)
let str1 = Ctypes.string_of (ptr (ptr lzma_stream)) streampp in
let str2 = Ctypes.string_of (ptr lzma_stream) (!@ streampp) in
let str3 = Ctypes.string_of lzma_stream (!@ (!@ streampp)) in
Printf.printf "lzma_deinit (): *%s -> %s\n" str1 str2;
Printf.printf "lzma_deinit (): %s\n" str3;
Out_channel.flush Out_channel.stdout;
(* Because of stupid bug in liblzma to prevent segfaulting
* we just free() the data manually *)
libc_free (safe_getf stream stream_internal)
(* lzma_finalize streampp *)
So this is why I commented lzma_finalize streampp
and instead call libc_free (safe_getf stream stream_internal)
. If I uncomment and remove libc_free
it will crash with "Heap corruption" error.
This is why I try to free the biggest chunk of the stream structure with this manual libc_free
. But if you keep program unpacking for a long time it still leaks substantially.
So the only way is to bug xz-utils developers to fix this problem.
Just to make it clear that your code is reusable.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.