{"record":{"id":"c6add0aa8f54c4ea","repo":"apache/hadoop","slug":"einval-c6add0","errorCode":"EINVAL","errorMessage":"%s is not a multiple of sizeof(double)\\n","messagePattern":"(.+?) is not a multiple of sizeof\\(double\\)\\\\n","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/vecsum.c","lineNumber":503,"sourceCode":"        fprintf(stderr, \"hdfsOpenFile(%s) failed: error %d (%s)\\n\",\n            opts->path, err, strerror(err));\n        goto error;\n    }\n    ldata->length = opts->length;\n    return ldata;\n\nerror:\n    if (pinfo)\n        hdfsFreeFileInfo(pinfo, 1);\n    if (ldata)\n        libhdfs_data_free(ldata);\n    return NULL;\n}\n\nstatic int check_byte_size(int byte_size, const char *const str)\n{\n    if (byte_size % sizeof(double)) {\n        fprintf(stderr, \"%s is not a multiple \"\n            \"of sizeof(double)\\n\", str);\n        return EINVAL;\n    }\n    if ((byte_size / sizeof(double)) % DOUBLES_PER_LOOP_ITER) {\n        fprintf(stderr, \"The number of doubles contained in \"\n            \"%s is not a multiple of DOUBLES_PER_LOOP_ITER\\n\",\n            str);\n        return EINVAL;\n    }\n    return 0;\n}\n\n#ifdef HAVE_INTEL_SSE_INTRINSICS\n\n#include <emmintrin.h>\n\nstatic double vecsum(const double *buf, int num_doubles)\n{","sourceCodeStart":485,"sourceCodeEnd":521,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/vecsum.c#L485-L521","documentation":"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.","triggerScenarios":"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.","commonSituations":"Tuning the benchmark for different block/chunk sizes; porting vecsum to a platform where sizeof(double) != 8 (exotic ABIs).","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."],"exampleFix":"// before (vecsum.c)\n#define ZCR_READ_CHUNK_SIZE (1024 * 1024 * 8 + 4)\n// after\n#define ZCR_READ_CHUNK_SIZE (1024 * 1024 * 8)","handlingStrategy":"validation","validationCode":"/* fail the build instead of failing at runtime */\n_Static_assert(VECSUM_CHUNK_SIZE  % (int)sizeof(double) == 0, \"chunk must align to double\");\n_Static_assert(ZCR_READ_CHUNK_SIZE % (int)sizeof(double) == 0, \"chunk must align to double\");\n_Static_assert(NORMAL_READ_CHUNK_SIZE % (int)sizeof(double) == 0, \"chunk must align to double\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["libhdfs","c","vecsum","einval","alignment","compile-time-constants"],"backgroundTag":"size-alignment-validation-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}