From: Jan Kiszka <jan.kiszka@web.de>
To: "Meier, Hans" <Hans.Meier@zwick.de>,
"xenomai@xenomai.org" <xenomai@xenomai.org>
Subject: Re: [Xenomai] Corruption after phtread_mutex_destroy
Date: Fri, 24 Apr 2015 08:53:30 +0200 [thread overview]
Message-ID: <5539E86A.7000104@web.de> (raw)
In-Reply-To: <1b27d68cb89340489802b18862a2b2d7@zue-s-199.zue.zwick.de>
Am 2015-04-23 um 20:42 schrieb Meier, Hans:
> Hi everybody,
>
> First of all thanks a lot for your excellent work, we are using Xenomai
> for about 8 years now in quite a complex application together with ACE
> based on the POSIX skin and most of the time it just works fine.
>
> But now we have a situation we think needs to be reported.
>
> Consider the following:
> We have a thread H with high priority, a thread L with low priority and
> a mutex M (recursive, prio-inherit). L locks M and then H tries to lock M,
> L gets boosted until it unlocks M, then H succeeds in locking M, then H
> unlocks M. If H then immediately destroys and frees M, we get a corruption
> where M's pthread_mutex_t was stored (a byte gets decremented), as soon as
> L gets scheduled again.
>
> According to man page PTHREAD_MUTEX_DESTROY(3P), section "Destroying
> Mutexes" - close to the end - "Implementations are required to allow an
> object to be destroyed and freed ... immediately after the object is
> unlocked". So that is what we do here, we destroy and free the mutex
> immediately after it is unlocked. Certainly in a simple scenario we could
> easily work around this problem by destroying and freeing M later, but
> what if this code is buried deep inside a framework lib (here ACE)?
Not saying that ACE is to be blamed in this case (until the issue is
fully understood), but that layer is in general a rather problematic
piece of code (politely expressed).
In most projects I saw so far, it was of limited or even no real use
anymore. And it caused quite some headache due to lots of bugs,
specifically regarding concurrency, even in its "matured" parts.
So, if possible, get rid of it, at least on the long run.
Jan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
URL: <http://www.xenomai.org/pipermail/xenomai/attachments/20150424/725a3be9/attachment.sig>
next prev parent reply other threads:[~2015-04-24 6:53 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-23 18:42 [Xenomai] Corruption after phtread_mutex_destroy Meier, Hans
2015-04-23 19:03 ` Gilles Chanteperdrix
2015-04-23 19:27 ` Gilles Chanteperdrix
2015-04-24 6:53 ` Jan Kiszka [this message]
2015-04-24 15:18 ` Gilles Chanteperdrix
2015-04-24 15:23 ` Jan Kiszka
2015-04-24 15:26 ` Gilles Chanteperdrix
2015-04-24 15:31 ` Jan Kiszka
2015-04-24 15:35 ` Gilles Chanteperdrix
2015-04-24 16:02 ` Jan Kiszka
2015-04-27 9:39 ` Meier, Hans
2015-04-27 11:47 ` Gilles Chanteperdrix
2015-04-27 13:11 ` Meier, Hans
2015-04-27 13:20 ` Gilles Chanteperdrix
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=5539E86A.7000104@web.de \
--to=jan.kiszka@web.de \
--cc=Hans.Meier@zwick.de \
--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.