From 571dca5715bb53f26099d77c04a175f716ab48ae Mon Sep 17 00:00:00 2001 From: Gilad S Date: Sun, 5 May 2024 00:06:50 +0300 Subject: [PATCH] fix: use `malloc` instead of `posix_memalign` in `ggml-metal.m` to make it not crash Electron proccesses --- ggml-metal.m | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ggml-metal.m b/ggml-metal.m index 017b72ce9..5434daa79 100644 --- a/ggml-metal.m +++ b/ggml-metal.m @@ -264,10 +264,9 @@ static void ggml_metal_log(enum ggml_log_level level, const char * format, ...){ } static void * ggml_metal_host_malloc(size_t n) { - void * data = NULL; - const int result = posix_memalign((void **) &data, sysconf(_SC_PAGESIZE), n); - if (result != 0) { - GGML_METAL_LOG_ERROR("%s: error: posix_memalign failed\n", __func__); + void * data = malloc(n); + if (data == null) { + GGML_METAL_LOG_ERROR("%s: error: malloc failed\n", __func__); return NULL; }