BurntSushi / rust-snappy

Snappy compression implemented in Rust (including the Snappy frame format).
BSD 3-Clause "New" or "Revised" License
444 stars 43 forks source link

Example decompressor fails against Mark Twin sample #22

Closed lespea closed 4 years ago

lespea commented 5 years ago

Maybe I'm doing something wrong but I get a StreamHeader panic when I try decompressing the test file.

adam@pc: ~/devel/rust-snappy master
$ RUST_BACKTRACE=1 cargo run --release --example decompress <data/Mark.Twain-Tom.Sawyer.txt.rawsnappy
   Compiling libc v0.2.48
   Compiling byteorder v1.3.1
   Compiling rand_core v0.4.0
   Compiling lazy_static v1.2.0
   Compiling rand_core v0.3.1
   Compiling rand_core v0.2.2
   Compiling snap v0.2.5 (/home/adam/devel/rust-snappy)
   Compiling rand v0.5.6
   Compiling quickcheck v0.7.2
    Finished release [optimized + debuginfo] target(s) in 5.40s
     Running `target/release/examples/decompress`
thread 'main' panicked at 'I/O operation failed: Custom { kind: Other, error: StreamHeader { byte: 216 } }', src/libcore/result.rs:1009:5
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/sys_common/backtrace.rs:59
             at src/libstd/panicking.rs:211
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:227
   4: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:491
   5: std::panicking::continue_panic_fmt
             at src/libstd/panicking.rs:398
   6: rust_begin_unwind
             at src/libstd/panicking.rs:325
   7: core::panicking::panic_fmt
             at src/libcore/panicking.rs:95
   8: core::result::unwrap_failed
             at /rustc/9fda7c2237db910e41d6a712e9a2139b352e558b/src/libcore/macros.rs:26
   9: decompress::main
             at /rustc/9fda7c2237db910e41d6a712e9a2139b352e558b/src/libcore/result.rs:835
             at examples/decompress.rs:12
  10: std::rt::lang_start::{{closure}}
             at /rustc/9fda7c2237db910e41d6a712e9a2139b352e558b/src/libstd/rt.rs:74
  11: std::panicking::try::do_call
             at src/libstd/rt.rs:59
             at src/libstd/panicking.rs:310
  12: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:102
  13: std::rt::lang_start_internal
             at src/libstd/panicking.rs:289
             at src/libstd/panic.rs:398
             at src/libstd/rt.rs:58
  14: main
  15: __libc_start_main
  16: _start
FAIL: 101

adam@pc: ~/devel/rust-snappy master
$ cargo version
cargo 1.32.0 (8610973aa 2019-01-02)
lespea commented 5 years ago

I tried using the snappytool from the golang library and it appeared to work okay.

BurntSushi commented 5 years ago

I literally can't do anything to help you if you don't share your code. In the future, when filling issues on open source projects, please try to make as much information available as possible. It is important for others to be able to reproduce your problem. If you don't share your code, then reproducing the problem is typically very difficult because it requires us maintainers to guess. Overall, it leads to a giant waste of time. So please just include the code from the start.

If possible, include the smallest amount of code possible that shows the problem.

lespea commented 5 years ago

I literally showed you how to recreate the issue in my code block... I'm not sure what else you need?

Just clone this repo and run this: RUST_BACKTRACE=1 cargo run --release --example decompress <data/Mark.Twain-Tom.Sawyer.txt.rawsnappy

BurntSushi commented 5 years ago

Sorry, that wasn't at all clear to me.

On Wed, Feb 6, 2019, 11:05 Adam Lesperance <notifications@github.com wrote:

I literally showed you how to recreate the issue in my code block... I'm not sure what else you need?

Just clone this repo and run this: RUST_BACKTRACE=1 cargo run --release --example decompress <data/Mark.Twain-Tom.Sawyer.txt.rawsnappy

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/BurntSushi/rust-snappy/issues/22#issuecomment-461079535, or mute the thread https://github.com/notifications/unsubscribe-auth/AAb34q47iQLSx-CaMJDAJ_fWsX54EiYxks5vKv1YgaJpZM4akyQc .

lespea commented 5 years ago

Np. I'll try to be more clear in future issues

bopohaa commented 5 years ago

This example use streamin protocol for decode data. The specified file is encoded without using a stream algorithm - https://github.com/google/snappy/blob/master/framing_format.txt First byte is not a 0xFF header marker for streamin

BurntSushi commented 4 years ago

Yes, @bopohaa has it right. As the file extension suggests, the file is formatted as a raw snappy file. But the example you're using uses the Snappy frame format. You can either change the example to use the raw format, or use the szip tool included in this repository:

$ szip -r -d < data/Mark.Twain-Tom.Sawyer.txt.rawsnappy