From: Mathieu Desnoyers Date: Wed, 6 Apr 2022 14:55:11 +0000 (-0400) Subject: Fix: don't use strerror() from ust lock nocheck X-Git-Tag: v2.12.5~2 X-Git-Url: http://git.lttng.org/?p=lttng-ust.git;a=commitdiff_plain;h=94e6e686bf0a1a62de6d5d31fee783506b53ac1f Fix: don't use strerror() from ust lock nocheck ust_lock_nocheck is meant to be async-signal-safe for use from the fork() override helper (and fork(2) is async-signal-safe). Remove calls to strerror() from ust lock functions and from the cancelstate helper because strerror is not async-signal-safe and indeed allocates memory. Signed-off-by: Mathieu Desnoyers Change-Id: I461f3631a24e71232d987b0a984b4942903bf9ac --- diff --git a/liblttng-ust-comm/ust-cancelstate.c b/liblttng-ust-comm/ust-cancelstate.c index 0611ce25..3027449d 100644 --- a/liblttng-ust-comm/ust-cancelstate.c +++ b/liblttng-ust-comm/ust-cancelstate.c @@ -27,7 +27,7 @@ int lttng_ust_cancelstate_disable_push(void) goto end; ret = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate); if (ret) { - ERR("pthread_setcancelstate: %s", strerror(ret)); + ERR("pthread_setcancelstate: ret=%d", ret); return -1; } state->oldstate = oldstate; @@ -46,7 +46,7 @@ int lttng_ust_cancelstate_disable_pop(void) goto end; ret = pthread_setcancelstate(state->oldstate, &oldstate); if (ret) { - ERR("pthread_setcancelstate: %s", strerror(ret)); + ERR("pthread_setcancelstate: ret=%d", ret); return -1; } if (oldstate != PTHREAD_CANCEL_DISABLE) { diff --git a/liblttng-ust/lttng-ust-comm.c b/liblttng-ust/lttng-ust-comm.c index f3222699..92d590d4 100644 --- a/liblttng-ust/lttng-ust-comm.c +++ b/liblttng-ust/lttng-ust-comm.c @@ -139,13 +139,13 @@ int ust_lock(void) sigfillset(&sig_all_blocked); ret = pthread_sigmask(SIG_SETMASK, &sig_all_blocked, &orig_mask); if (ret) { - ERR("pthread_sigmask: %s", strerror(ret)); + ERR("pthread_sigmask: ret=%d", ret); } if (!URCU_TLS(ust_mutex_nest)++) pthread_mutex_lock(&ust_mutex); ret = pthread_sigmask(SIG_SETMASK, &orig_mask, NULL); if (ret) { - ERR("pthread_sigmask: %s", strerror(ret)); + ERR("pthread_sigmask: ret=%d", ret); } if (lttng_ust_comm_should_quit) { return -1; @@ -171,13 +171,13 @@ void ust_lock_nocheck(void) sigfillset(&sig_all_blocked); ret = pthread_sigmask(SIG_SETMASK, &sig_all_blocked, &orig_mask); if (ret) { - ERR("pthread_sigmask: %s", strerror(ret)); + ERR("pthread_sigmask: ret=%d", ret); } if (!URCU_TLS(ust_mutex_nest)++) pthread_mutex_lock(&ust_mutex); ret = pthread_sigmask(SIG_SETMASK, &orig_mask, NULL); if (ret) { - ERR("pthread_sigmask: %s", strerror(ret)); + ERR("pthread_sigmask: ret=%d", ret); } } @@ -192,13 +192,13 @@ void ust_unlock(void) sigfillset(&sig_all_blocked); ret = pthread_sigmask(SIG_SETMASK, &sig_all_blocked, &orig_mask); if (ret) { - ERR("pthread_sigmask: %s", strerror(ret)); + ERR("pthread_sigmask: ret=%d", ret); } if (!--URCU_TLS(ust_mutex_nest)) pthread_mutex_unlock(&ust_mutex); ret = pthread_sigmask(SIG_SETMASK, &orig_mask, NULL); if (ret) { - ERR("pthread_sigmask: %s", strerror(ret)); + ERR("pthread_sigmask: ret=%d", ret); } if (lttng_ust_cancelstate_disable_pop()) { ERR("lttng_ust_cancelstate_disable_pop");