From: Mathieu Desnoyers Date: Wed, 16 Mar 2016 13:55:10 +0000 (-0400) Subject: Fix: remove assertions in lttng-ust-comm init X-Git-Tag: v2.8.0-rc1~1 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=8aadb54abbf7c13e8eb8f0554c517c6bfbc9ea0c;p=lttng-ust.git Fix: remove assertions in lttng-ust-comm init Assertions in the lttng-ust-comm init function are slightly too harsh for their own good. In situations involving incoherent seccomp profiles (e.g. accepting futex, poll, nanosleep, clock_nanosleep, but not restart_syscall), unexpected errno values can be returned by sem_timedwait. Print an error in those situations, but let the application proceed. Signed-off-by: Mathieu Desnoyers --- diff --git a/liblttng-ust/lttng-ust-comm.c b/liblttng-ust/lttng-ust-comm.c index 8a568328..e00a22ce 100644 --- a/liblttng-ust/lttng-ust-comm.c +++ b/liblttng-ust/lttng-ust-comm.c @@ -1590,7 +1590,9 @@ void __attribute__((constructor)) lttng_ust_init(void) timeout_mode = get_constructor_timeout(&constructor_timeout); ret = sem_init(&constructor_wait, 0, 0); - assert(!ret); + if (ret) { + PERROR("sem_init"); + } ret = setup_local_apps(); if (ret) { @@ -1655,17 +1657,34 @@ void __attribute__((constructor)) lttng_ust_init(void) ret = sem_timedwait(&constructor_wait, &constructor_timeout); } while (ret < 0 && errno == EINTR); - if (ret < 0 && errno == ETIMEDOUT) { - ERR("Timed out waiting for lttng-sessiond"); - } else { - assert(!ret); + if (ret < 0) { + switch (errno) { + case ETIMEDOUT: + ERR("Timed out waiting for lttng-sessiond"); + break; + case EINVAL: + PERROR("sem_timedwait"); + break; + default: + ERR("Unexpected error \"%s\" returned by sem_timedwait", + strerror(errno)); + } } break; case -1:/* wait forever */ do { ret = sem_wait(&constructor_wait); } while (ret < 0 && errno == EINTR); - assert(!ret); + if (ret < 0) { + switch (errno) { + case EINVAL: + PERROR("sem_wait"); + break; + default: + ERR("Unexpected error \"%s\" returned by sem_wait", + strerror(errno)); + } + } break; case 0: /* no timeout */ break;