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-Url: http://git.liburcu.org/?p=lttng-ust.git;a=commitdiff_plain;h=ab64db3571ab2b39a2218f81b3483768f815822a 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/src/lib/lttng-ust-common/ust-cancelstate.c b/src/lib/lttng-ust-common/ust-cancelstate.c index 7835803b..e42c7b4e 100644 --- a/src/lib/lttng-ust-common/ust-cancelstate.c +++ b/src/lib/lttng-ust-common/ust-cancelstate.c @@ -28,7 +28,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; @@ -47,7 +47,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/src/lib/lttng-ust/lttng-ust-comm.c b/src/lib/lttng-ust/lttng-ust-comm.c index caba7452..384a6a58 100644 --- a/src/lib/lttng-ust/lttng-ust-comm.c +++ b/src/lib/lttng-ust/lttng-ust-comm.c @@ -134,13 +134,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; @@ -166,13 +166,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); } } @@ -187,13 +187,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");