GithubHelp home page GithubHelp logo

assertion failed about libflate HOT 12 CLOSED

sile avatar sile commented on June 16, 2024
assertion failed

from libflate.

Comments (12)

sile avatar sile commented on June 16, 2024

Is it possible to tell me how to reproduce the error?
If the problematic file is publicly accessible, it will be helpful if you let me know its URL.

I tried to decode some gzip files downloaded from s3 (e.g., emsdk-portable.tar.gz ), but no problem was found.

from libflate.

dovahcrow avatar dovahcrow commented on June 16, 2024

Sorry there're some sensitive data inside the file so I cannot give it to you directly.
I added these to huffman.rs: 97 and saw some interesting results.

    for padding in 0..(1 << (self.max_bitwidth - code.width)) {
            let i = ((padding << code.width) | code_be.bits) as usize;
            if i == 0 {
                println!("
                symbol: {}
                code: Code {{ width: {}, bits: {:b} }}
                code_be.bits: {:b}
                i: {} 
                self.max_bitwidth: {}
                padding: {} 
                value: {}",
                         symbol,
                         code.width,
                         code.bits,
                         code_be.bits,
                         i,
                         self.max_bitwidth,
                         padding,
                         value)
            }
            debug_assert_eq!(self.table[i], MAX_BITWIDTH as u16 + 1);
            unsafe {
                *self.table.get_unchecked_mut(i) = value;
            }

Prints:

                symbol: 0
                code: Code { width: 3, bits: 0 }
                code_be.bits: 0
                i: 0
                self.max_bitwidth: 7
                padding: 0
                value: 3

                symbol: 48
                code: Code { width: 5, bits: 0 }
                code_be.bits: 0
                i: 0
                self.max_bitwidth: 15
                padding: 0
                value: 1541

                symbol: 230
                code: Code { width: 13, bits: 10000000000000 }
                code_be.bits: 0
                i: 0
                self.max_bitwidth: 15
                padding: 0
                value: 7373

It seems like the index 0 has been repeatedly used.

from libflate.

sile avatar sile commented on June 16, 2024

Thank you for your information.

It seems like the index 0 has been repeatedly used.

Typically, it indicates that "the input data is broken".
DecoderBuilder::set_mapping method (and its callers) tries to reconstruct huffman codes from the canonical huffman codes stored in the input data.
But for some reason, the canonical huffman codes have used overlapped (conflicted) bits spaces for different symbols (so the assertion raised).

Of course, the cause may be simply a bug in the libflate.
But, unfortunately, there is no sufficient information to determine the exact reason of the error ... .

from libflate.

dovahcrow avatar dovahcrow commented on June 16, 2024

from libflate.

sile avatar sile commented on June 16, 2024

Hmm... .
I can not do it for a while because I do not have time, but if I can afford, I will try to reproduce it in my environment.

from libflate.

dovahcrow avatar dovahcrow commented on June 16, 2024

from libflate.

sile avatar sile commented on June 16, 2024

Thanks!

from libflate.

sile avatar sile commented on June 16, 2024

FYI, I fixed a bug (at the commit a03c2f3 ) which seems the cause of the problem reported by this issue.

from libflate.

dovahcrow avatar dovahcrow commented on June 16, 2024

from libflate.

sile avatar sile commented on June 16, 2024

Thanks!
I hope this will solve your problem.

from libflate.

dovahcrow avatar dovahcrow commented on June 16, 2024

Great, I can confirm the bug have been fixed! Thanks for your help!

from libflate.

sile avatar sile commented on June 16, 2024

Good!
Thank you for confirmation.
(And sorry for the inconvenience for a long time)

from libflate.

Related Issues (20)

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.