fix: Only munmap the wait page when not exiting from process
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 21 Feb 2012 17:41:18 +0000 (12:41 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 21 Feb 2012 17:41:18 +0000 (12:41 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
liblttng-ust/lttng-ust-comm.c

index d0641c5c6e510b01d0538d9c36b07c5c430644c6..dda4743fc240cf7c2dc7f71e15846a8ec2a691ca 100644 (file)
@@ -383,7 +383,7 @@ error:
 }
 
 static
-void cleanup_sock_info(struct sock_info *sock_info)
+void cleanup_sock_info(struct sock_info *sock_info, int exiting)
 {
        int ret;
 
@@ -402,7 +402,18 @@ void cleanup_sock_info(struct sock_info *sock_info)
                sock_info->root_handle = -1;
        }
        sock_info->constructor_sem_posted = 0;
-       if (sock_info->wait_shm_mmap) {
+       /*
+        * When called from process exit, we allow this memory map to be
+        * released by the OS at exit(), because removing it prior to
+        * this can cause a segmentation fault when using the
+        * futex_async timer-based fallback. And we cannot join those
+        * threads because sys_futex does not react to the cancellation
+        * request.
+        *
+        * So we actually _do_ release it only after a fork, since all
+        * threads have vanished anyway.
+        */
+       if (!exiting && sock_info->wait_shm_mmap) {
                ret = munmap(sock_info->wait_shm_mmap, sysconf(_SC_PAGE_SIZE));
                if (ret) {
                        ERR("Error unmapping wait shm");
@@ -876,9 +887,9 @@ void __attribute__((constructor)) lttng_ust_init(void)
 static
 void lttng_ust_cleanup(int exiting)
 {
-       cleanup_sock_info(&global_apps);
+       cleanup_sock_info(&global_apps, exiting);
        if (local_apps.allowed) {
-               cleanup_sock_info(&local_apps);
+               cleanup_sock_info(&local_apps, exiting);
        }
        lttng_ust_abi_exit();
        lttng_ust_events_exit();
@@ -923,6 +934,10 @@ void __attribute__((destructor)) lttng_ust_exit(void)
                        ERR("Error cancelling local ust listener thread");
                }
        }
+       /*
+        * We cannot join the threads because they might be waiting on
+        * sys_futex. Simply let the OS exit() clean up those threads.
+        */
        lttng_ust_cleanup(1);
 }
 
This page took 0.027391 seconds and 4 git commands to generate.