]> git.kaiwu.me - haproxy.git/commit
REGTESTS: compression: check hard to compress contents and nearly full buffers
authorWilly Tarreau <w@1wt.eu>
Sat, 31 Oct 2026 08:21:13 +0000 (09:21 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 3 Nov 2026 08:40:36 +0000 (09:40 +0100)
commit078e0aa87aae0bcb64ad53bf758a2f01dd9690fc
treea7652c227fb1e0e03195a3d7a34aae955e1ab4f3
parent7a65e029f1a99b0127422107503c06b9dfc931b5
REGTESTS: compression: check hard to compress contents and nearly full buffers

Add reg-tests/compression/output_margin_*.vtc, with a Lua service in
output_margin.lua, which sends bodies that are incompressible or barely
compressible (random bytes, bytes that cost 9 bits each with the fixed
tree, random data mixed with text, random data with short matches, runs
of 9-bit literals separated by 4-byte matches) or repetitive. The service
serves the cases of the set named in the request in order, so that the
vtest clients just loop over the same request. Each response must be
compressed with gzip, and is decompressed by the client, which checks the
gzip trailer's CRC and length, then compares the body length to the one
announced in x-len.

The tests are split into several files so that vtest runs them in
parallel, and tagged slow:
  - output_margin_{whole,buf,small,odd}.vtc send all patterns through 4 kB
    buffers, whole or by calls of 4000, 1 to 64 or 1 to 20000 bytes;
  - output_margin_full_{random,run51}.vtc use 16 kB buffers and
    tune.maxrewrite 32, so that the buffer may be almost full when the
    filter compresses it, with bodies of 16088 to 16116 bytes sent in one
    call. With the default maxrewrite, the channel always keeps far more
    room than the deflater could ever need, which is why this does not
    happen with default settings. These sizes still leave enough room for
    the deflater, so they must be compressed as well (responses of 16144
    bytes or more are not compressed at all with this setup).

Before the fixes, the last two crashed haproxy in comp_http_payload()
(htx_get_blk_type() on the NULL block returned by htx_replace_blk_value())
for all sizes from 16086 to 16118 bytes, which is the crash reported since
3.5-dev10. Each file takes about as long as a trivial test (0.25 to 0.3s
without ASAN here, 0.33 to 0.42s with ASAN).
reg-tests/compression/output_margin.lua [new file with mode: 0644]
reg-tests/compression/output_margin_buf.vtc [new file with mode: 0644]
reg-tests/compression/output_margin_full_random.vtc [new file with mode: 0644]
reg-tests/compression/output_margin_full_run51.vtc [new file with mode: 0644]
reg-tests/compression/output_margin_odd.vtc [new file with mode: 0644]
reg-tests/compression/output_margin_small.vtc [new file with mode: 0644]
reg-tests/compression/output_margin_whole.vtc [new file with mode: 0644]