Fix 32-bit zstdmt max job size allocation failure

This commit is contained in:
Danyal Ahmed 2026-05-18 23:57:55 +05:00
parent 5233c58e6c
commit a2a05b95c3
2 changed files with 15 additions and 2 deletions

View file

@ -32,8 +32,8 @@
#ifndef ZSTDMT_JOBSIZE_MIN /* a different value can be selected at compile time */
# define ZSTDMT_JOBSIZE_MIN (512 KB)
#endif
#define ZSTDMT_JOBLOG_MAX (MEM_32bits() ? 29 : 30)
#define ZSTDMT_JOBSIZE_MAX (MEM_32bits() ? (512 MB) : (1024 MB))
#define ZSTDMT_JOBLOG_MAX (MEM_32bits() ? 28 : 30)
#define ZSTDMT_JOBSIZE_MAX (MEM_32bits() ? (256 MB) : (1024 MB))
/* ========================================================

View file

@ -3907,6 +3907,19 @@ static int basicUnitTests(U32 const seed, double compressibility)
}
}
DISPLAYLEVEL(3, "test%3i : job size bounds match architecture : ", testNb++);
{ ZSTD_bounds const bounds = ZSTD_cParam_getBounds(ZSTD_c_jobSize);
#ifdef ZSTD_MULTITHREAD
int const expectedJobSizeMax = MEM_32bits() ? (256 MB) : (1024 MB);
#else
int const expectedJobSizeMax = 0;
#endif
CHECK_Z(bounds.error);
if (bounds.lowerBound != 0) goto _output_error;
if (bounds.upperBound != expectedJobSizeMax) goto _output_error;
}
DISPLAYLEVEL(3, "OK \n");
/* advanced parameters for decompression */
{ ZSTD_DCtx* const dctx = ZSTD_createDCtx();
assert(dctx != NULL);