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:46:10 +0000 (15:46 -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

liblttng-ust-comm/ust-cancelstate.c
liblttng-ust/lttng-ust-comm.c

index 0611ce256b9e2bf3f43d66551c9de275dd195637..3027449ddf436a9b49248d47fcdab96a82dff91f 100644 (file)
@@ -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) {
index f3222699d7814395ac60a78fa22c445df2c91c5b..92d590d408f0f7093d128cdb105f84c969b07ad4 100644 (file)
@@ -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");
This page took 0.032543 seconds and 4 git commands to generate.