From edea8013ea262aa31b40368a09edce121c845088 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Wed, 6 Apr 2022 10:55:11 -0400 Subject: [PATCH] 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 --- src/lib/lttng-ust-common/ust-cancelstate.c | 4 ++-- src/lib/lttng-ust/lttng-ust-comm.c | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) 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 6a1dc376..e63ee835 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"); -- 2.34.1