<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 7, 2015 at 12:48 PM, Jérémie Galarneau <span dir="ltr"><<a href="mailto:jeremie.galarneau@efficios.com" target="_blank">jeremie.galarneau@efficios.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">LTTng-UST will deadlock waiting on the "constructor_wait" semaphore<br>
if local apps, handled the session daemon running under the current UID,<br>
are disabled or "not_allowed".<br>
<br>
This deadlock can be triggered by setting an infinite registration<br>
timeout and clearing the HOME environment variable, which will cause<br>
setup_local_apps() to fail to determine the local_apps sock_path, thus<br>
leaving local_apps.allowed == 0.<br>
<br>
Given that local_apps are not allowed at this point, the local_apps<br>
listener thread will not be launched. Therefore, the constructor_wait<br>
will not be waited on.<br></blockquote><div><br></div><div>This should say "will not be posted".</div><div><br></div><div>Jérémie</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
The fix proposed here consists in decrementing "sem_count" if an error<br>
precluding the launch the the local_apps listener thread occurs.<br>
<br>
Signed-off-by: Jérémie Galarneau <<a href="mailto:jeremie.galarneau@efficios.com">jeremie.galarneau@efficios.com</a>><br>
---<br>
liblttng-ust/lttng-ust-comm.c | 18 +++++++++++++++---<br>
1 file changed, 15 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/liblttng-ust/lttng-ust-comm.c b/liblttng-ust/lttng-ust-comm.c<br>
index b290204..c91627f 100644<br>
--- a/liblttng-ust/lttng-ust-comm.c<br>
+++ b/liblttng-ust/lttng-ust-comm.c<br>
@@ -373,6 +373,7 @@ void print_cmd(int cmd, int handle)<br>
static<br>
int setup_local_apps(void)<br>
{<br>
+ int ret = 0;<br>
const char *home_dir;<br>
uid_t uid;<br>
<br>
@@ -382,13 +383,16 @@ int setup_local_apps(void)<br>
*/<br>
if (uid != geteuid()) {<br>
assert(local_apps.allowed == 0);<br>
- return 0;<br>
+ goto end;<br>
}<br>
home_dir = get_lttng_home_dir();<br>
if (!home_dir) {<br>
WARN("HOME environment variable not set. Disabling LTTng-UST per-user tracing.");<br>
assert(local_apps.allowed == 0);<br>
- return -ENOENT;<br>
+ ret = -ENOENT;<br>
+ goto end;<br>
+ } else {<br>
+ DBG("home_dir: %s", home_dir);<br>
}<br>
local_apps.allowed = 1;<br>
snprintf(local_apps.sock_path, PATH_MAX, "%s/%s/%s",<br>
@@ -398,7 +402,15 @@ int setup_local_apps(void)<br>
snprintf(local_apps.wait_shm_path, PATH_MAX, "/%s-%u",<br>
LTTNG_UST_WAIT_FILENAME,<br>
uid);<br>
- return 0;<br>
+end:<br>
+ if (!local_apps.allowed) {<br>
+ /*<br>
+ * Don't wait on the "local" listener thread since we won't be<br>
+ * communicating with the local session daemon.<br>
+ */<br>
+ uatomic_add(&sem_count, -1);<br>
+ }<br>
+ return ret;<br>
}<br>
<br>
/*<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.4.4<br>
<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Jérémie Galarneau<br>EfficiOS Inc.<br><a href="http://www.efficios.com" target="_blank">http://www.efficios.com</a></div>
</div></div>