Fix: only cleanup the agent_apps_ht_by_sock as root
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 20 lines · Julien Desfossez
Commit
6a4e403927ffef4cae8726064dcf53c463eb128cintroduced a bug where we could end up iterating over theagent_apps_ht_by_sockregardless if it was allocated or not (only when the sessiond is launched as root).Steps to reproduce:
$ sudo lttng-sessiond -d $ lttng-sessiond Error: Already running daemon. Segmentation fault (core dumped)Signed-off-by Julien Desfossez <[email protected]>--- src/bin/lttng-sessiond/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)src/bin/lttng-sessiond/main.c +0
-0
src/bin/lttng-sessiond/main.c static void sessiond_cleanup(void) · line 684
Quoted 9 lines
src/bin/lttng-sessiond/main.c +3
-1@@ -677,7 +677,9 @@ static void sessiond_cleanup(void) }DBG ("Cleaning up all agent apps" ); -agent_app_ht_clean (); +if (is_root) { +agent_app_ht_clean (); + }
This will leak the hash table if the session daemon was launched as an unprivileged user. However, the problem can also be reproduced by launching two session daemons under the same unprivileged user.
The real issue here seems to be that the session daemon will enter the "exit_init_data" code path before creating the hash table if it can't acquire the lock file and that there are no NULL checks performed during the sessiond_cleanup().
Thanks,
Jérémie
Quoted 6 lines
src/bin/lttng-sessiond/main.c +0
-0DBG ("Closing all UST sockets" );ust_app_clean_list();--
1.9.1
Signature · 3 lines
Jérémie Galarneau EfficiOS Inc. http://www.efficios.com
_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
A message that is not in the archive (sent off-list or not yet received): CA+jJMxtq7wLdQnf8QH97hY9=1f5jcs6O9dpKTkghxP5w=FktPQ@mail.gmail.com
Here is my proposed fix. Can you test it on your end?
https://github.com/jgalar/lttng-tools/commits/sessiond-agent-crash
commit 5e249e09a2bd68f96e546bf83b4710596518f675
Author: Jérémie Galarneau <[email protected]> Date: Thu Jul 30 12:48:52 2015 -0400
Clean-up: Move agent_apps_ht_by_sock definition to main.c
commit 1af8b99faa625033f9e0c2a6eaa9b3006cfadadd
Author: Jérémie Galarneau <[email protected]> Date: Thu Jul 30 12:46:56 2015 -0400
Fix: Initialize global agent_apps_ht_by_sock on session daemon launch
Jérémie
Quoted 60 lines · Jérémie Galarneau
Quoted 20 lines · Julien Desfossez
Commit
6a4e403927ffef4cae8726064dcf53c463eb128cintroduced a bug where we could end up iterating over theagent_apps_ht_by_sockregardless if it was allocated or not (only when the sessiond is launched as root).Steps to reproduce:
$ sudo lttng-sessiond -d $ lttng-sessiond Error: Already running daemon. Segmentation fault (core dumped)Signed-off-by Julien Desfossez <[email protected]>--- src/bin/lttng-sessiond/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)src/bin/lttng-sessiond/main.c +0
-0src/bin/lttng-sessiond/main.c static void sessiond_cleanup(void) · line 684
Quoted 9 lines
src/bin/lttng-sessiond/main.c +3
-1@@ -677,7 +677,9 @@ static void sessiond_cleanup(void) }DBG ("Cleaning up all agent apps" ); -agent_app_ht_clean (); +if (is_root) { +agent_app_ht_clean (); + }This will leak the hash table if the session daemon was launched as an unprivileged user. However, the problem can also be reproduced by launching two session daemons under the same unprivileged user.
The real issue here seems to be that the session daemon will enter the "
exit_init_data" code path before creating the hash table if it can't acquire the lock file and that there are no NULL checks performed during thesessiond_cleanup().Thanks,
JérémieQuoted 6 lines
src/bin/lttng-sessiond/main.c +0
-0DBG ("Closing all UST sockets" );ust_app_clean_list();--
1.9.1--
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
Signature · 3 lines
Jérémie Galarneau EfficiOS Inc. http://www.efficios.com
_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
A message that is not in the archive (sent off-list or not yet received): CA+jJMxtDov8wEtZp=T3+2LRieRjAcfMQ6WxESgzaw+Gj1KhfKw@mail.gmail.com
I confirm it fixes the problem I was seeing.
Thanks,
Julien
Quoted 111 lines · Jérémie Galarneau
Here is my proposed fix. Can you test it on your end?
https://github.com/jgalar/lttng-tools/commits/sessiond-agent-crash
commit
5e249e09a2bd68f96e546bf83b4710596518f675
Author: Jérémie Galarneau <[email protected] <mailto:[email protected]>>
Date: Thu Jul 30 12:48:52 2015 -0400Clean-up: Move
agent_apps_ht_by_sockdefinition tomain.cSigned-off-by Jérémie Galarneau <[email protected]<mailto:[email protected]>>
commit
1af8b99faa625033f9e0c2a6eaa9b3006cfadadd
Author: Jérémie Galarneau <[email protected] <mailto:[email protected]>>
Date: Thu Jul 30 12:46:56 2015 -0400Fix: Initialize global
agent_apps_ht_by_sockon session daemon launchSigned-off-by Jérémie Galarneau <[email protected]<mailto:[email protected]>>
Jérémie
On Thu, Jul 30, 2015 at 12:02 PM, Jérémie Galarneau <[email protected] <mailto:[email protected]>> wrote:
On Thu, Jul 30, 2015 at 11:12 AM, Julien Desfossez <[email protected] <mailto:[email protected]>> wrote:
Commit
6a4e403927ffef4cae8726064dcf53c463eb128cintroduced a bug where
we could end up iterating over theagent_apps_ht_by_sockregardless if
it was allocated or not (only when the sessiond is launched as root).Steps to reproduce:
$ sudo lttng-sessiond -d
$ lttng-sessiond
Error: Already running daemon.
Segmentation fault (core dumped)Signed-off-by Julien Desfossez <[email protected]<mailto:[email protected]>>
---
src/bin/lttng-sessiond/main.c| 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)diff --git
a/src/bin/lttng-sessiond/main.cb/src/bin/lttng-sessiond/main.c
index 91dd047..5840165 100644
---a/src/bin/lttng-sessiond/main.c
+++b/src/bin/lttng-sessiond/main.c
@@ -677,7 +677,9 @@ static voidsessiond_cleanup(void)
}
DBG("Cleaning up all agent apps");
-agent_app_ht_clean();
+ if (is_root) {
+agent_app_ht_clean();
+ }This will leak the hash table if the session daemon was launched as an unprivileged user. However, the problem can also be reproduced by launching two session daemons under the same unprivileged user.
The real issue here seems to be that the session daemon will enter the "
exit_init_data" code path before creating the hash table if it can't acquire the lock file and that there are no NULL checks performed during thesessiond_cleanup().Thanks,
Jérémie
DBG("Closing all UST sockets");
ust_app_clean_list();
--
1.9.1--
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.comSignature · 9 lines
Jérémie Galarneau EfficiOS Inc. http://www.efficios.com _______________________________________________ lttng-dev mailing list [email protected] http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev