Skip to content

1 GiB file bug #3239

@ip7z

Description

@ip7z

zstd 1.5.2 doesn't reduce the Windows Size from 2 GiB to 1 GiB, if file size is exactly 1 GiB.

To Reproduce

FSUtil File CreateNew 1024 0x40000000
zstd --long=31 -1 --single-thread --no-content-size -f 1024
zstd -l -v 1024.zst

result:

Window Size: 2.00 GiB (2147483648 B)

Expected behavior

Window Size: 1.00 GiB

Source code lines
the bug probably in function ZSTD_adjustCParams_internal() in zstd_compress.c:

    const U64 maxWindowResize = 1ULL << (ZSTD_WINDOWLOG_MAX-1);
   ... 
    /* resize windowLog if input is small enough, to use less memory */
    if ( (srcSize < maxWindowResize)

and fixed version probably must use <= instead of <:

    if ( (srcSize <= maxWindowResize)

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions