{"record":{"id":"fae12bcb188e84da","repo":"apache/hadoop","slug":"malloc-d-failed","errorCode":null,"errorMessage":"malloc(%d) failed\n","messagePattern":"malloc\\((.+?)\\) failed\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/test_libhdfs_zerocopy.c","lineNumber":52,"sourceCode":"#define TO_STR(X) TO_STR_HELPER(X)\n\n#define TEST_FILE_NAME_LENGTH 128\n#define TEST_ZEROCOPY_FULL_BLOCK_SIZE 4096\n#define TEST_ZEROCOPY_LAST_BLOCK_SIZE 3215\n#define TEST_ZEROCOPY_NUM_BLOCKS 6\n#define SMALL_READ_LEN 16\n#define TEST_ZEROCOPY_FILE_LEN \\\n  (((TEST_ZEROCOPY_NUM_BLOCKS - 1) * TEST_ZEROCOPY_FULL_BLOCK_SIZE) + \\\n    TEST_ZEROCOPY_LAST_BLOCK_SIZE)\n\n#define ZC_BUF_LEN 32768\n\nstatic uint8_t *getZeroCopyBlockData(int blockIdx)\n{\n    uint8_t *buf = malloc(TEST_ZEROCOPY_FULL_BLOCK_SIZE);\n    int i;\n    if (!buf) {\n        fprintf(stderr, \"malloc(%d) failed\\n\", TEST_ZEROCOPY_FULL_BLOCK_SIZE);\n        exit(1);\n    }\n    for (i = 0; i < TEST_ZEROCOPY_FULL_BLOCK_SIZE; i++) {\n      buf[i] = (uint8_t)(blockIdx + (i % 17));\n    }\n    return buf;\n}\n\nstatic int getZeroCopyBlockLen(int blockIdx)\n{\n    if (blockIdx >= TEST_ZEROCOPY_NUM_BLOCKS) {\n        return 0;\n    } else if (blockIdx == (TEST_ZEROCOPY_NUM_BLOCKS - 1)) {\n        return TEST_ZEROCOPY_LAST_BLOCK_SIZE;\n    } else {\n        return TEST_ZEROCOPY_FULL_BLOCK_SIZE;\n    }\n}","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/test_libhdfs_zerocopy.c#L34-L70","documentation":"Error \"malloc(%d) failed\n\" thrown in apache/hadoop.","triggerScenarios":"malloc returned NULL when test_libhdfs_zerocopy allocated its read buffer.","commonSituations":"Memory exhaustion on the test host, or an unrealistically large buffer length configured for the zerocopy test.","solutions":["Reduce the requested allocation (TEST_ZEROCOPY_PORTION / buffer size) to fit available memory.","Run on a host with more free RAM or raise the process memory limit (ulimit -v).","Check for a bug passing an excessively large size to malloc in the test arguments."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}