This is an automated email from the ASF dual-hosted git repository.
chengdong pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 0d12f82074f sched/misc: fix incorrect mutex holder retrieval in assert
backtrace
0d12f82074f is described below
commit 0d12f82074f6422733a870904ac780c5042b6c4d
Author: chenzhaoxiang <[email protected]>
AuthorDate: Thu Feb 26 16:48:34 2026 +0800
sched/misc: fix incorrect mutex holder retrieval in assert backtrace
The dump_lockholder() function in assert.c was directly accessing
themutex->holder
member variable to print the mutex holder's thread ID inthe backtrace log.
This is
incorrect because the holder field is aprivate implementation detail of the
mutex structure,
and the properAPI nxmutex_get_holder() should be used to retrieve the
holder ID.
Using the public API ensures consistency with mutex state management,avoids
potential issues
with future changes to the mutex structure'sinternal layout, and adheres to
the kernel's
encapsulation principles.
This fix corrects the log output to show the accurate mutex holder IDwhen
assertion failures
related to mutex locks occur, improving thedebuggability of lock-related
issues.
Signed-off-by: chao an <[email protected]>
---
sched/misc/assert.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sched/misc/assert.c b/sched/misc/assert.c
index 0da9ec54cf8..42491c25a58 100644
--- a/sched/misc/assert.c
+++ b/sched/misc/assert.c
@@ -576,7 +576,7 @@ static void dump_lockholder(pid_t tid)
backtrace_format(buf, sizeof(buf), mutex->backtrace,
CONFIG_LIBC_MUTEX_BACKTRACE);
- _alert("Mutex holder(%d) backtrace:%s\n", mutex->holder, buf);
+ _alert("Mutex holder(%d) backtrace:%s\n", nxmutex_get_holder(mutex), buf);
}
#else
# define dump_lockholder(tid)