-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New compression functions #209
Conversation
Hey, I saw this PR, got excited about the potential (didn't profile this yet) speed-up, skimmed the changes and saw that you used some Therefore I tried to verify the error and it looks like there is indeed an out of bounds read in additional check to reproducediff --git a/utils/src/compression/decomp/mod.rs b/utils/src/compression/decomp/mod.rs
index f7bfd9c..c7443c2 100644
--- a/utils/src/compression/decomp/mod.rs
+++ b/utils/src/compression/decomp/mod.rs
@@ -38,6 +38,12 @@ pub(super) fn unpack_bytes(buf: &mut [u8], diff: &[u8]) {
diff_idx += 1;
for _ in 0..to_cpy {
+ if diff_idx + 4 > len {
+ panic!(
+ "index out of range: diff_idx={diff_idx} diff_idx+4={} len={len}",
+ diff_idx + 4
+ );
+ }
unsafe { std::ptr::copy_nonoverlapping(diff.add(diff_idx), buf.add(pix_idx * 4), 4) }
diff_idx += 3;
pix_idx += 1; I only skimmed the code and you certainly understand the code better than me, but I wanted to point this out and maybe you know if this is a problem or just miri (and me) being noisy :) |
Thanks a lot for pointing that out, @Akida31. Interestingly, this is a problem that also existed in the previous implementation! It just hadn't blown up yet. I've gone ahead and added some |
91fe1d5
to
1d52cfe
Compare
1d52cfe
to
ce0e6ff
Compare
ce0e6ff
to
6d71c12
Compare
I ran miri after that and it looks like the errors are gone now.
But these are just my thoughts and not blocking concerns for this PR, feel free to decide which of these points are good and which to ignore. |
Also reduce mininum lz4 version and fix access out of bounds in decompressor.
6d71c12
to
112858d
Compare
I think your 1st and 2nd point are very valid, and I've gone ahead and documented most of the usage of unsafe and their soundness requirements. Regarding your 3rd point, I just don't like Thanks a lot for your guidance and reviews! |
This overhauls the current api for compressing animated frames.
The new api is more explicit about errors, does better checking for preconditions, and is faster.
We've dropped
lzzzz
in favor of just linking the lz4 system library directly. lz4 was already listed as one of our dependencies, so this should be fine.We've also included hand-written SIMD implementations to further speed up both compression and decompression. Note that LZ4 takes the most amount of time when it comes to compression and decompression, so, even though this is nice, it won't make a world of difference.