Giter Club home page Giter Club logo

ocaml-lzma's People

Contributors

xvilka avatar

Watchers

 avatar  avatar

ocaml-lzma's Issues

liblzma from xz-utils is not thread-safe

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.

Add a LICENSE

Just to make it clear that your code is reusable.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.