rpc: remove backend handle from global map when freed#7517
rpc: remove backend handle from global map when freed#7517chraac wants to merge 1 commit intoggml-org:masterfrom
Conversation
| GGML_CALL static void ggml_backend_rpc_free(ggml_backend_t backend) { | ||
| ggml_backend_rpc_context * rpc_ctx = (ggml_backend_rpc_context *)backend->context; | ||
| ggml_backend_rpc_buffer_type_context * buft_ctx = (ggml_backend_rpc_buffer_type_context *)rpc_ctx->buft->context; | ||
| instances.erase(rpc_ctx->endpoint); |
There was a problem hiding this comment.
Should we lock the map when changing its content? Will it be accessed from multi thread?
|
Unfortunately this doesn't solve the problem in all cases. For example in I am working on a fix and will submit a PR shortly. |
so there's another place that keep the |
|
please take a look at PR #7562 |
Found an app crash occurring when trying to reload a new llm model after another model has been unloaded.
When built with ASan, it shows a
heap-buffer-overflowerror inggml_backend_rpc_get_device_memory. The relevant log is as follows:Upon investigating the source code, discovered that in
ggml-rpc.cpp, theggml_backend_tinstances are stored in a map calledinstances. However, inside theggml_backend_rpc_freefunction, we forgot to remove theggml_backend_titem from the map when it is freed:ggml-rpc.cpp#L531
Here we insert
ggml_backend_tinto map:ggml-rpc.cpp#L679