BrianPugh/tamp

Decompressor in C creates wrong output

DeeFuse opened this issue · 8 comments

Using the C code to compress and decompress a file does not result in the same uncompressed output.

The compressor produces the same output as the Python implementation but the C decomressor corrupts the data.
The first few bytes are correct but later into the decompression more and more bytes are wrong.

I used VisualStudio 2022 to build tamp as a x86 binary.

Thanks for the bug report! Can you share the specific data that triggers this bug? Trying to figure out if it's some edge case in the compression algorithm, or it's some platform incompatibility that I need to fix. Thanks!

I've teste it with 663 bytes of binary data, mostly 0x00 (60%) and also ran a test using 1024 byte "Lorem ipsum" text as plaintext.

I got some "converting const uint16_t to uint8_t" warnings, but adjusting the functions did not change the output.

I've created a VS2022 project that demonstrates my problem:
TampTest.zip

Can you share the code you are using to decompress? Just trying to narrow down the problem; the CLI uses the C decompressor by default and I haven't been able to observe any decompression corruption.

I used the code from the c-profiler to test the functionality.

You can also have a look into the attached zip in my last comment.

I just manually tested the pip-installed CLI on windows (I rarely use windows) with the enwik8 dataset, as well as a 10,000 long lorem ipsum, and everything is working on fine, so going to need more information to reproduce.

EDIT: we were typing at the same time, looking at your stuff now :D

you are correct, there must be a bug in the c-profiler code (honestly, that code was pretty rushed). I don't believe the bug is in the library itself, but in that script. I'll be investigating shortly and keep you updated. Issue is unrelated to Windows.

Addressed in #18. I'll be releasing this and some minor performance improvements later today in v1.1.4. Thank you very much for the bug report!

fixed in v1.1.4