Skip to content

Fix decompression corruption for small offsets (3, 5, 6, 7)#233

Merged
404Setup merged 1 commit intomainfrom
fix-decompress-offset-7-4913898284605405552
Feb 18, 2026
Merged

Fix decompression corruption for small offsets (3, 5, 6, 7)#233
404Setup merged 1 commit intomainfrom
fix-decompress-offset-7-4913898284605405552

Conversation

@404Setup
Copy link
Copy Markdown
Owner

Fixed a data corruption bug in the generic decompression implementation (decompress_huffman_block) where offsets 3, 5, 6, and 7 used unsafe memory reads. Refactored x86 implementation to match. Verified with test_offset_7_pattern and full test suite.


PR created automatically by Jules for task 4913898284605405552 started by @404Setup

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]>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@404Setup 404Setup merged commit cbc39e8 into main Feb 18, 2026
1 check passed
@404Setup 404Setup deleted the fix-decompress-offset-7-4913898284605405552 branch February 18, 2026 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant