#1810·lz4

CLI silently ignores custom -B block sizes (bytes) in multithreaded builds since v1.10.0

Author: ZbysekzCreated Sep 25, 2026Updated Sep 25, 2026

Describe the bug

lz4 --help documents custom block sizes: -B# : ... # bytes [32+]. Since v1.10.0 this feature is silently ignored in default (multithreaded) builds: the CLI prints e.g. using blocks of size 2 KB, but the produced frame contains blocks cut at the declared blockSizeID class size (64 KB minimum). -T1 does not help — the single-thread code path is only selected at compile time (LZ4IO_MULTITHREAD=0), not at run time.

Cause

(from reading programs/lz4io.c, still present on dev): the v1.10 thread-pool rewrite LZ4IO_compressFilename_extRess_MT() cuts input into hard-coded 4 MB jobs and compresses each job with a single LZ4F_compressUpdate() call, so lz4frame cuts blocks at the blockSizeID class size. io_prefs->blockSize (the exact value stored by LZ4IO_setBlockSize()) is never consulted. The legacy single-thread path LZ4IO_compressFilename_extRess_ST() still honors it (reads blockSize bytes per iteration with autoFlush=1).

Expected behavior lz4 -B2048 file should produce frame blocks of 2048 bytes of content each, as in single-thread builds of the same source, and as the printed message claims. Blocks smaller than the declared class maximum are a valid frame layout, and stock lz4 decodes such files fine.

To Reproduce Steps to reproduce the behavior:

seq 1 20000 > input.txt (~109 KB) lz4 -B2048 -BI --no-frame-crc input.txt out.lz4 — prints using blocks of size 2 KB Inspect the frame: it contains 2 blocks (~51 KB and ~29 KB compressed, i.e. 64 KB of content each) instead of ~54 blocks of ≤2048 bytes. Build the same source with -DLZ4IO_MULTITHREAD=0 and repeat step 2: the output now correctly contains 54 blocks of ≤2048 bytes, and the default multithreaded binary decompresses that file without complaint. Quick block-size dump used for step 3 (walks [u32 LE length][block] after the 7-byte header):

import struct
d = open('out.lz4','rb').read(); off = 7; sizes = []
while True:
    (n,) = struct.unpack_from('<I', d, off); off += 4
    if n == 0: break
    sizes.append(n & 0x7fffffff); off += n & 0x7fffffff
print(len(sizes), max(sizes))

System:

OS: Linux (x86_64) Version: lz4 v1.10.0 (also reproduced on current dev, 0774d055) Compiler: gcc Build System: Makefile (default build, LZ4IO_MULTITHREAD=1) Other hardware specs: not hardware-specific

Additional context Our use case is streaming .lz4 files to a small embedded receiver on the satellite. (Cortex-M7, ~350 KB heap): with 64 KB blocks, safe decompression needs ~128 KB of buffers; with 2 KB blocks, a few KB.

PR here: Pull request