Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ggml : fix memory leaks when loading invalid gguf files #10094

Merged
merged 4 commits into from
Oct 30, 2024
Merged

Conversation

slaren
Copy link
Collaborator

@slaren slaren commented Oct 30, 2024

If reading a KV entry fails, the key name and array data of the last entry will not be freed. I believe this was done intentionally to avoid calling free on uninitialized pointers, but that should already be prevented with the use of calloc.

@slaren slaren marked this pull request as ready for review October 30, 2024 11:51
@slaren
Copy link
Collaborator Author

slaren commented Oct 30, 2024

Also removed some GGML_ABORT on invalid types. Hopefully this will address at least some of the leak reports in the fuzzer.

@github-actions github-actions bot added the ggml changes relating to the ggml tensor library for machine learning label Oct 30, 2024
@slaren slaren changed the title ggml : fix gguf string leak when reading kv pairs fails ggml : fix memory leaks when loading invalid gguf files Oct 30, 2024
@slaren slaren merged commit b9e02e8 into master Oct 30, 2024
54 checks passed
@slaren slaren deleted the sl/fix-gguf-leak branch October 30, 2024 13:51
arthw pushed a commit to arthw/llama.cpp that referenced this pull request Nov 15, 2024
)

* ggml : fix gguf string leak when reading kv pairs fails

* ggml : avoid crashing with GGML_ABORT when the KV has an invalid type

* ggml : avoid crashing on failed memory allocations when loading a gguf file
arthw pushed a commit to arthw/llama.cpp that referenced this pull request Nov 18, 2024
)

* ggml : fix gguf string leak when reading kv pairs fails

* ggml : avoid crashing with GGML_ABORT when the KV has an invalid type

* ggml : avoid crashing on failed memory allocations when loading a gguf file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ggml changes relating to the ggml tensor library for machine learning
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants