leejet / stable-diffusion.cpp

Stable Diffusion in pure C/C++
MIT License
2.91k stars 233 forks source link

App crashes silently since the last update when loading a new model. #206

Closed Jonathhhan closed 3 months ago

Jonathhhan commented 3 months ago

Thats how it was working before:

        if (sd_ctx != NULL) {
            free_sd_ctx(sd_ctx);
        }
        sd_ctx = new_sd_ctx(&thread->modelPath[0], &thread->vaePath[0],  &thread->taesdPath[0], &thread->controlNetPath[0], &thread->loraModelDir[0], &thread->embedDir[0], &thread->stackedIdEmbedDir[0], thread->isVaeDecodeOnly, thread->isVaeTiling, thread->isFreeParamsImmediatly, thread->numThreads, thread->sdType, thread->rngType, thread->schedule, thread->keepClipOnCpu, thread->keepControlNetCpu, thread->keepVaeOnCpu);

Now it works, if I do not free the sd_ctx. But then the memory from the old context is still allocated.

DarthAffe commented 3 months ago

I can confirm this using the C-API in .NET. Calling free_sd_ctx causes a silent crash with error code 0xc0000374 (HEAP corruption)

Jonathhhan commented 3 months ago

The issue is solved by PR https://github.com/leejet/stable-diffusion.cpp/pull/200