google / google/brotli

C: Compressing large input data triggers an assert (with BROTLI_DEBUG=1)

Open
#1,389 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
14.9k
Forks
1.4k
Avg merge
4d 20h
Merged PRs (30d)
9

Description

Trying to compress large input data triggers an assert:
```enc/hash_longest_match64_simd_inc.h:198: FindLongestMatchH68: Assertion `cur_ix_masked + max_length <= ring_buffer_mask' failed.```

If quality is set to 6, input data larger than 33554431 bytes will trigger the assert.
If I reduce BROTLI_PARAM_LGWIN / --lgwin, the assert will be triggered for smaller data sizes.

I was not able to reproduce it with version 1.1.0.

### How to reproduce:
1. Compile with BROTLI_DEBUG=1.
2. `head -c 33554432 /dev/urandom > large-file && brotli --quality=6 --force large-file --output=large-file.out`
3. `head -c 8388607 /dev/urandom > large-file && brotli --quality=6 --force large-file --output=large-file.out --lgwin=21`

Contributor guide

Open the contributing guide

Research direction

Start with enc/hash_longest_match64_simd_inc.h at FindLongestMatchH68 and reproduce the assertion using BROTLI_DEBUG=1 with the provided brotli commands and input sizes. Trace how quality, lgwin, and the ring buffer affect the failing assertion, then verify that large inputs no longer abort under both reproduction cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.