From: gabriel.pollo-guilbert@efficios.com (Gabriel-Andrew Pollo-Guilbert)
Subject: [lttng-dev] [PATCH lttng-ust] Ignore unexpected old state when nesting ust_mutex in the same thread
Date: Tue, 28 May 2019 12:18:37 -0400 [thread overview]
Message-ID: <20190528161837.29477-1-gabriel.pollo-guilbert@efficios.com> (raw)
We allow the ust_mutex lock to be nested within the same thread using the
ust_mutex_nest counter. When calling ust_lock(), ust_lock_nocheck() or
ust_unlock() twice or more in the same thread would result in an error
message being thrown.
This error message always appear when an application calls fork(3) (with
liblttng-ust-fork preloaded), the thread would lock before the fork(3) in
ust_before_fork() and the child would lock again during lttng_after_fork_child().
Signed-off-by: Gabriel-Andrew Pollo-Guilbert <gabriel.pollo-guilbert at efficios.com>
---
liblttng-ust/lttng-ust-comm.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/liblttng-ust/lttng-ust-comm.c b/liblttng-ust/lttng-ust-comm.c
index 61dbb41b..a6449bbc 100644
--- a/liblttng-ust/lttng-ust-comm.c
+++ b/liblttng-ust/lttng-ust-comm.c
@@ -135,7 +135,9 @@ int ust_lock(void)
ERR("pthread_setcancelstate: %s", strerror(ret));
}
if (oldstate != PTHREAD_CANCEL_ENABLE) {
- ERR("pthread_setcancelstate: unexpected oldstate");
+ if (!URCU_TLS(ust_mutex_nest)) {
+ ERR("pthread_setcancelstate: unexpected oldstate");
+ }
}
sigfillset(&sig_all_blocked);
ret = pthread_sigmask(SIG_SETMASK, &sig_all_blocked, &orig_mask);
@@ -171,7 +173,9 @@ void ust_lock_nocheck(void)
ERR("pthread_setcancelstate: %s", strerror(ret));
}
if (oldstate != PTHREAD_CANCEL_ENABLE) {
- ERR("pthread_setcancelstate: unexpected oldstate");
+ if (!URCU_TLS(ust_mutex_nest)) {
+ ERR("pthread_setcancelstate: unexpected oldstate");
+ }
}
sigfillset(&sig_all_blocked);
ret = pthread_sigmask(SIG_SETMASK, &sig_all_blocked, &orig_mask);
@@ -210,7 +214,9 @@ void ust_unlock(void)
ERR("pthread_setcancelstate: %s", strerror(ret));
}
if (oldstate != PTHREAD_CANCEL_DISABLE) {
- ERR("pthread_setcancelstate: unexpected oldstate");
+ if (URCU_TLS(ust_mutex_nest)) {
+ ERR("pthread_setcancelstate: unexpected oldstate");
+ }
}
}
--
2.21.0
reply other threads:[~2019-05-28 16:18 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20190528161837.29477-1-gabriel.pollo-guilbert@efficios.com \
--to=gabriel.pollo-guilbert@efficios.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox