From 3b07c7af10ea0b0884a6cc4735480ef6397eb2eb Mon Sep 17 00:00:00 2001 From: Steffen Moeller Date: Wed, 25 Feb 2026 21:14:49 +0000 Subject: [PATCH] fix: tooldata_mmap: explicitly initialize mutex MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit explicitly initialize the mutex, instead of calling tool_mmap_mutex_give() without a prior lock. Mutex is “given” without an initial successful “try/get” In src/emc/tooldata/tooldata_mmap.cc:163, tool_mmap_creator() calls tool_mmap_mutex_give() right after setup without any prior lock acquisition. That is unusual and potentially undefined depending on rtapi_mutex semantics. --- docs/man/man3/rtapi_mutex.3rtapi | 2 +- src/emc/tooldata/tooldata_mmap.cc | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/man/man3/rtapi_mutex.3rtapi b/docs/man/man3/rtapi_mutex.3rtapi index 9118f7b9f45..c69a0d39845 100644 --- a/docs/man/man3/rtapi_mutex.3rtapi +++ b/docs/man/man3/rtapi_mutex.3rtapi @@ -36,4 +36,4 @@ init/cleanup, and realtime code. \fBrtapi_mutex_try\fR returns 0 for if the mutex was claimed, and nonzero otherwise. -\fBrtapi_mutex_get\fR and \fBrtapi_mutex_gif\fR have no return value. +\fBrtapi_mutex_get\fR and \fBrtapi_mutex_give\fR have no return value. diff --git a/src/emc/tooldata/tooldata_mmap.cc b/src/emc/tooldata/tooldata_mmap.cc index 72a0b73f73c..a1fa9add1f7 100644 --- a/src/emc/tooldata/tooldata_mmap.cc +++ b/src/emc/tooldata/tooldata_mmap.cc @@ -155,11 +155,12 @@ int tool_mmap_creator(EMC_TOOL_STAT const * ptr,int random_toolchanger) } tooldata_header_t *hptr = HPTR(); + hptr->mutex = 0; hptr->is_random_toolchanger = random_toolchanger; hptr->last_index = 0; inited = 1; - tool_mmap_mutex_give(); return 0; + return 0; } // tool_mmap_creator(); //typ: milltask, guis (emcmodule,emcsh,...), halui