Fix decompression corruption for small offsets (3, 5, 6, 7)#233
Fix decompression corruption for small offsets (3, 5, 6, 7)#233
Conversation
The generic decompression logic in `src/decompress/mod.rs` (`decompress_huffman_block`) contained unsafe optimizations for offsets 3, 5, 6, and 7. These optimizations performed unaligned 8-byte reads from the source pointer (`dest - offset`) that extended into uninitialized destination memory. This Undefined Behavior caused data corruption, manifesting as single-byte errors in `test_offset_7_pattern`. This patch: 1. Removes the unsafe optimized blocks for offsets 3, 5, 6, and 7 in `src/decompress/mod.rs`, falling back to a safe scalar copy loop. 2. Removes similar complex/buggy SIMD logic for offsets 3, 5, 6, 7 in `src/decompress/x86.rs` to ensure correctness and simplicity, as the fast path logic mirrored the flawed approach. 3. Fixes `test_offset_7_pattern` failure. The issue was difficult to diagnose because `test_offset_7_pattern` uses a small input buffer, causing `decompress_bmi2` (fast path) to be skipped in favor of the generic `decompress_huffman_block` (slow path), masking changes made only to the x86 implementation. Co-authored-by: 404Setup <[email protected]>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Fixed a data corruption bug in the generic decompression implementation (
decompress_huffman_block) where offsets 3, 5, 6, and 7 used unsafe memory reads. Refactoredx86implementation to match. Verified withtest_offset_7_patternand full test suite.PR created automatically by Jules for task 4913898284605405552 started by @404Setup