]> git.djapps.eu Git - pkg/ggml/sources/ggml/commitdiff
rpc: fix segfault on invalid endpoint format (llama/18387)
authoro7si <redacted>
Sun, 28 Dec 2025 10:34:41 +0000 (18:34 +0800)
committerGeorgi Gerganov <redacted>
Wed, 31 Dec 2025 10:39:43 +0000 (12:39 +0200)
* rpc: fix segfault on invalid endpoint format

* rpc: add error log for failed endpoint connection

src/ggml-rpc/ggml-rpc.cpp

index e7890a5ee935448dfb56f9b3e8f7d7fefa06b21d..164b39d01e2d89c9e71fd3693a5edb48ad6dfd09 100644 (file)
@@ -524,6 +524,7 @@ static std::shared_ptr<socket_t> get_socket(const std::string & endpoint) {
     std::string host;
     int port;
     if (!parse_endpoint(endpoint, host, port)) {
+        GGML_LOG_ERROR("Failed to parse endpoint: %s\n", endpoint.c_str());
         return nullptr;
     }
 #ifdef _WIN32
@@ -2053,6 +2054,10 @@ ggml_backend_reg_t ggml_backend_rpc_reg(void) {
 
 static uint32_t ggml_backend_rpc_get_device_count(const char * endpoint) {
     auto sock = get_socket(endpoint);
+    if (sock == nullptr) {
+        GGML_LOG_ERROR("Failed to connect to %s\n", endpoint);
+        return 0;
+    }
     rpc_msg_device_count_rsp response;
     bool status = send_rpc_cmd(sock, RPC_CMD_DEVICE_COUNT, nullptr, 0, &response, sizeof(response));
     RPC_STATUS_ASSERT(status);