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

  1. 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.
  2. 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

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


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/c6add0aa8f54c4ea. Report an issue: GitHub.