{"record":{"id":"024b632df169ca2e","repo":"apple/pkl","slug":"failed-to-allocate-pkl-exec-t","errorCode":null,"errorMessage":"failed to allocate pkl_exec_t\n","messagePattern":"failed to allocate pkl_exec_t\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"libpkl/src/main/c/pkl.c","lineNumber":140,"sourceCode":"}\n\nint pkl_init(pkl_message_response_handler handler, void *userData,\n\t\tpkl_exec_t **exec, pkl_error_t *error) {\n\tif (handler == NULL) {\n\t\tif (error != NULL) {\n\t\t\terror->message = \"handler is null\";\n\t\t}\n\t\treturn -1;\n\t}\n\tif (exec == NULL) {\n\t\tif (error != NULL) {\n\t\t\terror->message = \"exec is null\";\n\t\t}\n\t\treturn -1;\n\t}\n\tpkl_exec_t *pexec = calloc(1, sizeof(pkl_exec_t));\n\tif (pexec == NULL) {\n\t\tfprintf(stderr, \"failed to allocate pkl_exec_t\\n\");\n\t\tabort();\n\t}\n\n\tpexec->handler = handler;\n\tpexec->userData = userData;\n\n\tgraal_isolate_t *isolate;\n\tgraal_isolatethread_t *isolateThread;\n\n\tif (graal_create_isolate(NULL, &isolate, &isolateThread) != 0) {\n\t\tif (error != NULL) {\n\t\t\terror->message = \"Failed to create graal isolate thread\";\n\t\t}\n\t\tfree(pexec);\n\t\t*exec = NULL;\n\t\treturn -1;\n\t}\n\tpexec->isolate = isolate;","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/libpkl/src/main/c/pkl.c#L122-L158","documentation":"Allocation check in pkl_init: calloc for the pkl_exec_t handle returned NULL (out of memory), so initialization cannot proceed and the process aborts. Input at fault: none — this is a sentinel allocation-failure path during library initialization.","triggerScenarios":"Thrown at libpkl/src/main/c/pkl.c:140 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Free memory or reduce process memory pressure before initializing libpkl.","Check ulimit/cgroup memory limits for the embedding process."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f3efcbfc9b60d30053b0536d664948d7aa1b8673","analyzedAt":"2026-09-08T13:10:45.570Z","contentChangedAt":"2026-09-08T13:10:45.570Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}