From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Jan Kiszka <jan.kiszka@domain.hid>
Cc: xenomai-core <xenomai@xenomai.org>
Subject: Re: [Xenomai-core] [PATCH 2/2] Provide owner name via rt_mutex_inquire
Date: Thu, 10 Jul 2008 17:11:40 +0200 [thread overview]
Message-ID: <487626AC.1080804@domain.hid> (raw)
In-Reply-To: <48762472.3000901@domain.hid>
[-- Attachment #1: Type: text/plain, Size: 1970 bytes --]
Jan Kiszka wrote:
> Gilles Chanteperdrix wrote:
>> Jan Kiszka wrote:
>>> This can be helpful for debugging the (futile) release attempts of
>>> mutexes by tasks that do not own them.
>>>
>>> Returning the RT_TASK reference may appear more consistent on first
>>> sight, but it cannot be guaranteed that the owner is actually a native
>>> task. Therefore this patch uses the symbolic name.
>>>
>>> Signed-off-by: Jan Kiszka <jan.kiszka@domain.hid>
>>> ---
>>> include/native/mutex.h | 3 +++
>>> ksrc/skins/native/mutex.c | 5 +++++
>>> 2 files changed, 8 insertions(+)
>>>
>>> Index: b/include/native/mutex.h
>>> ===================================================================
>>> --- a/include/native/mutex.h
>>> +++ b/include/native/mutex.h
>>> @@ -38,6 +38,9 @@ typedef struct rt_mutex_info {
>>>
>>> char name[XNOBJECT_NAME_LEN]; /**< Symbolic name. */
>>>
>>> + char owner[XNOBJECT_NAME_LEN]; /**< Symbolic name of the current
>>> owner,
>>> + empty if unlocked. */
>>> +
>>> } RT_MUTEX_INFO;
>>>
>>> typedef struct rt_mutex_placeholder {
>>> Index: b/ksrc/skins/native/mutex.c
>>> ===================================================================
>>> --- a/ksrc/skins/native/mutex.c
>>> +++ b/ksrc/skins/native/mutex.c
>>> @@ -597,6 +597,11 @@ int rt_mutex_inquire(RT_MUTEX *mutex, RT
>>> strcpy(info->name, mutex->name);
>>> info->lockcnt = mutex->lockcnt;
>>> info->nwaiters = xnsynch_nsleepers(&mutex->synch_base);
>>> + if (mutex->lockcnt)
>>> + strcpy(info->owner,
>>> + xnthread_name(xnsynch_owner(&mutex->synch_base)));
>> xnthread_name is not necessarily null terminated, so I would suggest to
>
> In fact, that is lethal for other users as well (trace points and proc
> dumps come to my mind) and should be fixed ASAP.
I propose the following patch then. It should solve the issue at the source.
--
Gilles.
[-- Attachment #2: xeno-xnobject_copy_name-use-snprintf.diff --]
[-- Type: text/plain, Size: 472 bytes --]
Index: include/nucleus/types.h
===================================================================
--- include/nucleus/types.h (r������vision 4004)
+++ include/nucleus/types.h (copie de travail)
@@ -97,7 +97,7 @@ typedef atomic_flags_t xnflags_t;
static inline void xnobject_copy_name(char *dst, const char *src)
{
if (src)
- strncpy(dst, src, XNOBJECT_NAME_LEN);
+ snprintf(dst, XNOBJECT_NAME_LEN, "%s", src);
else
*dst = '\0';
}
next prev parent reply other threads:[~2008-07-10 15:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-10 13:17 [Xenomai-core] [PATCH 2/2] Provide owner name via rt_mutex_inquire Jan Kiszka
2008-07-10 14:33 ` Gilles Chanteperdrix
2008-07-10 15:02 ` Jan Kiszka
2008-07-10 15:11 ` Gilles Chanteperdrix [this message]
2008-07-10 15:14 ` Philippe Gerum
2008-07-11 12:54 ` Gilles Chanteperdrix
2008-07-31 16:28 ` Philippe Gerum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=487626AC.1080804@domain.hid \
--to=gilles.chanteperdrix@xenomai.org \
--cc=jan.kiszka@domain.hid \
--cc=xenomai@xenomai.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.