Fix: don't use strerror() from ust lock nocheck
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 6 Apr 2022 14:55:11 +0000 (10:55 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 3 Jun 2022 19:44:17 +0000 (15:44 -0400)
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 <mathieu.desnoyers@efficios.com>
Change-Id: I461f3631a24e71232d987b0a984b4942903bf9ac

src/lib/lttng-ust-common/ust-cancelstate.c
src/lib/lttng-ust/lttng-ust-comm.c

index 7835803bdc3271acbf932880800fa2c7cb02f9f9..e42c7b4e21d1bcb0a8d0cb09867832d9ed6e5d98 100644 (file)
@@ -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) {
index caba7452eaafab2dfb7ccf570bb8fa83bf11be9e..384a6a582af8a2034c9678b31b400b4e33b95f50 100644 (file)
@@ -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");
This page took 0.027499 seconds and 4 git commands to generate.