apache/hadoop · error
EINVAL
EINVAL
Error message
%s is not a multiple of sizeof(double)\n
What it means
check_byte_size() is a compile-time-style sanity check vecsum runs (vecsum.c:769-773) over its chunk constants (VECSUM_CHUNK_SIZE, ZCR_READ_CHUNK_SIZE, NORMAL_READ_CHUNK_SIZE). Every constant must be a multiple of sizeof(double) because buffers are summed as doubles; if you edit the #defines and break 8-byte alignment, vecsum prints this and exits with EINVAL.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/vecsum.c:503
fprintf(stderr, "hdfsOpenFile(%s) failed: error %d (%s)\n",
opts->path, err, strerror(err));
goto error;
}
ldata->length = opts->length;
return ldata;
error:
if (pinfo)
hdfsFreeFileInfo(pinfo, 1);
if (ldata)
libhdfs_data_free(ldata);
return NULL;
}
static int check_byte_size(int byte_size, const char *const str)
{
if (byte_size % sizeof(double)) {
fprintf(stderr, "%s is not a multiple "
"of sizeof(double)\n", str);
return EINVAL;
}
if ((byte_size / sizeof(double)) % DOUBLES_PER_LOOP_ITER) {
fprintf(stderr, "The number of doubles contained in "
"%s is not a multiple of DOUBLES_PER_LOOP_ITER\n",
str);
return EINVAL;
}
return 0;
}
#ifdef HAVE_INTEL_SSE_INTRINSICS
#include <emmintrin.h>
static double vecsum(const double *buf, int num_doubles)
{View on GitHub (pinned to 2add963021)
Solutions
- Make every *_CHUNK_SIZE a multiple of sizeof(double); ideally keep them at multiples of 128 (8 * DOUBLES_PER_LOOP_ITER) to also satisfy the second check.
- Rebuild after fixing the constant.
Example fix
// before (vecsum.c) #define ZCR_READ_CHUNK_SIZE (1024 * 1024 * 8 + 4) // after #define ZCR_READ_CHUNK_SIZE (1024 * 1024 * 8)
Defensive patterns
Strategy: validation
Validate before calling
/* fail the build instead of failing at runtime */ _Static_assert(VECSUM_CHUNK_SIZE % (int)sizeof(double) == 0, "chunk must align to double"); _Static_assert(ZCR_READ_CHUNK_SIZE % (int)sizeof(double) == 0, "chunk must align to double"); _Static_assert(NORMAL_READ_CHUNK_SIZE % (int)sizeof(double) == 0, "chunk must align to double");
Prevention
- Treat the *_CHUNK_SIZE macros as fixed granularity: multiples of sizeof(double) * DOUBLES_PER_LOOP_ITER (128 bytes).
- Add _Static_assert lines next to the #defines so misalignment is caught at compile time.
- When tuning benchmark sizes, change the -l runtime argument, not the compile-time chunk constants.
When it happens
Trigger: Recompiling vecsum after changing a *_CHUNK_SIZE #define (vecsum.c:41-43) to a value that is not a multiple of 8 (e.g. 8*1024*1024 + 4). The check runs at startup on every invocation, not on user input.
Common situations: Tuning the benchmark for different block/chunk sizes; porting vecsum to a platform where sizeof(double) != 8 (exotic ABIs).
Related errors
- EINVAL
- hdfsOpenFile(%s) failed: error %d (%s)\n
- ENOMEM
- hdfsRead failed with error %d (%s)\n
- vecsum_length: stat(%s) failed: error %d (%s)\n
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/c6add0aa8f54c4ea.
Report an issue: GitHub.