trifectatechfoundation / zlib-rs

A safer zlib
zlib License
148 stars 15 forks source link

`zlib-ng` output is different on different platforms #91

Closed folkertdev closed 3 months ago

folkertdev commented 7 months ago

We observe that zlib-ng generates different output between x86 and aarch64. We (currently, anyway) generate the same output on both platforms. We don't know at this time why the difference is there.

The differences are only observed for larger inputs. At the time of writing, these tests fail on aarch64. The inputs are all in the tens of kilobytes, and we check that they encode to a specific sequence of bytes. We always do, but zlib-ng produces a different output (that we presume is valid and correct, just not byte-for-byte the same).

     Summary [   0.257s] 150 tests run: 147 passed, 3 failed, 0 skipped
        FAIL [   0.035s] zlib-rs deflate::test::compress_fireworks
        FAIL [   0.035s] zlib-rs deflate::test::compress_lcet10
        FAIL [   0.032s] zlib-rs deflate::test::compress_paper_100k
folkertdev commented 3 months ago

fuzzing like this

cargo +nightly fuzz run -s=leak end_to_end --target s390x-unknown-linux-gnu

with

[target.s390x-unknown-linux-gnu]
runner = "qemu-s390x -L /usr/s390x-linux-gnu"
linker = "s390x-linux-gnu-gcc"

finds examples that produce different output quickly.

folkertdev commented 3 months ago

https://github.com/memorysafety/zlib-rs/pull/155

fixes the final currently-known discrepancies.