-
Notifications
You must be signed in to change notification settings - Fork 631
fix: prevent crash in case of a mem alloc error and graceful exit #1566
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
base: master
Are you sure you want to change the base?
Changes from all commits
32e4f86
d3cc717
275d122
31d09c7
3c6904d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -999,6 +999,12 @@ bool ModelLoader::load_tensors(on_new_tensor_cb_t on_new_tensor_cb, int n_thread | |
| continue; | ||
| } | ||
|
|
||
| if (dst_tensor->data == nullptr) { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think
Could we instead propagate those failures there, e.g. check:
and return false with a component-level error message? The null-data check in |
||
| LOG_ERROR("process tensor data failed: '%s'", tensor_storage.name.c_str()); | ||
| failed = true; | ||
| break; | ||
| } | ||
|
|
||
| // skip mmapped tensors | ||
| if (dst_tensor->buffer != nullptr && dst_tensor->buffer == fdata.mmbuffer.get()) { | ||
| continue; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is the best place to check for this, because the allocation can't fail for individual tensors; it's all-or-nothing.
Take a look at
StableDiffusionGGML::init, instable-diffusion.cpp, a bit beforeload_tensors: some components do report allocation failure, but not all. We should probably propagate the underlyingalloc_params_buffererror in all cases.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have seen that code in stable-diffusion.cpp and wondered about the reasoning behind it. I am just a newbie, and I guess there is a reason for writing the code this way.
So I decided to keep that as is - and better add this little quick fix.
And you’re right, the allocation problem is an all-or-nothing issue. So the message refers to the first tensor and then the program exits.