{"record":{"id":"dd13d7ea016bb144","repo":"mudler/LocalAI","slug":"omnivoice-cpp-error-malloc-zu-failed-n","errorCode":null,"errorMessage":"[omnivoice-cpp] ERROR: malloc(%zu) failed\\n","messagePattern":"\\[omnivoice-cpp\\] ERROR: malloc\\(%zu\\) failed\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/go/omnivoice-cpp/cpp/gomnivoicecpp.cpp","lineNumber":113,"sourceCode":"    ov_tts_params tp;\n    fill_params(&tp, text, lang, instruct, ref_samples, ref_n, ref_text, seed,\n                denoise);\n\n    ov_audio out = {0};\n    enum ov_status rc = ov_synthesize(g_ctx, &tp, &out);\n    if (rc != OV_STATUS_OK || out.n_samples <= 0 || !out.samples) {\n        fprintf(stderr, \"[omnivoice-cpp] ERROR: synthesize failed (rc=%d): %s\\n\",\n                (int)rc, ov_last_error());\n        ov_audio_free(&out);\n        return nullptr;\n    }\n\n    // Copy into a plain malloc buffer the Go side can free symmetrically via\n    // omni_pcm_free; then release the ov_audio-owned buffer.\n    size_t bytes = (size_t)out.n_samples * sizeof(float);\n    float *buf = (float *)malloc(bytes);\n    if (!buf) {\n        fprintf(stderr, \"[omnivoice-cpp] ERROR: malloc(%zu) failed\\n\", bytes);\n        ov_audio_free(&out);\n        return nullptr;\n    }\n    memcpy(buf, out.samples, bytes);\n    if (out_n)\n        *out_n = out.n_samples;\n    ov_audio_free(&out);\n    return buf;\n}\n\nint omni_tts_stream(const char *text, const char *lang, const char *instruct,\n                    const float *ref_samples, int ref_n, const char *ref_text,\n                    long long seed, int denoise, omni_pcm_chunk_cb cb,\n                    void *user_data) {\n    if (!g_ctx) {\n        fprintf(stderr, \"[omnivoice-cpp] ERROR: model not loaded\\n\");\n        return 1;\n    }","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/mudler/LocalAI/blob/44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26/backend/go/omnivoice-cpp/cpp/gomnivoicecpp.cpp#L95-L131","documentation":"Memory allocation for the output PCM buffer failed. Guard: cap the maximum synthesis length/sample count before allocating, and return a resource-exhausted error to the caller rather than aborting the worker.","triggerScenarios":"Thrown at backend/go/omnivoice-cpp/cpp/gomnivoicecpp.cpp:113 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reduce the requested audio/text size so the output buffer fits in available memory.","Free system memory or increase available RAM/swap; check for memory leaks in long-running processes."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26","analyzedAt":"2026-08-15T10:13:50.291Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}