mudler/LocalAI · error

[qwen3-tts-cpp] ERROR: malloc(%zu) failed\n

Error message

[qwen3-tts-cpp] ERROR: malloc(%zu) failed\n

What it means

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.

Source

Thrown at backend/go/qwen3-tts-cpp/cpp/goqwen3ttscpp.cpp:130

    qt_tts_params tp;
    fill_params(&tp, text, lang, instruct, speaker, ref_samples, ref_n,
                ref_text, seed, temperature, top_k, top_p, repetition_penalty,
                max_new_tokens);

    qt_audio out = {0};
    enum qt_status rc = qt_synthesize(g_ctx, &tp, &out);
    if (rc != QT_STATUS_OK || out.n_samples <= 0 || !out.samples) {
        fprintf(stderr, "[qwen3-tts-cpp] ERROR: synthesize failed (rc=%d): %s\n",
                (int)rc, qt_last_error());
        qt_audio_free(&out);
        return nullptr;
    }

    // Copy into a plain malloc buffer the Go side frees via qt3_pcm_free.
    size_t bytes = (size_t)out.n_samples * sizeof(float);
    float *buf = (float *)malloc(bytes);
    if (!buf) {
        fprintf(stderr, "[qwen3-tts-cpp] ERROR: malloc(%zu) failed\n", bytes);
        qt_audio_free(&out);
        return nullptr;
    }
    memcpy(buf, out.samples, bytes);
    if (out_n)
        *out_n = out.n_samples;
    qt_audio_free(&out);
    return buf;
}

int qt3_tts_stream(const char *text, const char *lang, const char *instruct,
                   const char *speaker, const float *ref_samples, int ref_n,
                   const char *ref_text, long long seed, float temperature,
                   int top_k, float top_p, float repetition_penalty,
                   int max_new_tokens, qt3_chunk_cb cb, void *user_data) {
    if (!g_ctx) {
        fprintf(stderr, "[qwen3-tts-cpp] ERROR: model not loaded\n");
        return 1;

View on GitHub (pinned to 44413a9d06)

Solutions

  1. Reduce the requested output size so the buffer allocation succeeds.
  2. Free memory or add RAM/swap; investigate memory growth in the backend process.

When it happens

Trigger: Thrown at backend/go/qwen3-tts-cpp/cpp/goqwen3ttscpp.cpp:130 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of mudler/LocalAI@44413a9d06 (2026-08-15). Data as JSON: /api/errors/56c33b9807082730. Report an issue: GitHub.