diff --git a/src/heap-inl.h b/src/heap-inl.h index 1e2ed60e09417c481f07a51c59d9866baa7ebe81..cbe6a4764c22d82a015e5afd88c2e4f943c2850d 100644 --- a/src/heap-inl.h +++ b/src/heap-inl.h @@ -178,12 +178,19 @@ HEAP_EXPORT(void heap_remove(struct heap* heap, k -= 1; } - heap->nelts -= 1; - /* Unlink the max node. */ child = *max; *max = NULL; +#ifdef OHOS_USE_DFX + if (child == NULL) { + UV_LOGF("Child is NULL, this may be due to multi-threaded calls."); + return; + } +#endif + + heap->nelts -= 1; + if (child == node) { /* We're removing either the max or the last node in the tree. */ if (child == heap->min) { diff --git a/src/threadpool.c b/src/threadpool.c index 4a1ac04ad306b495898ab5dadf11b2691114e979..3aefe7c971e4a17a46d35e964cb649c3bdd0f943 100644 --- a/src/threadpool.c +++ b/src/threadpool.c @@ -313,9 +313,13 @@ int is_uv_loop_good_magic(const uv_loop_t* loop) { void on_uv_loop_close(uv_loop_t* loop) { time_t t1, t2; time(&t1); + uv_start_trace(UV_TRACE_TAG, "Get Write Lock"); uv_rwlock_wrlock(&g_closed_uv_loop_rwlock); + uv_end_trace(UV_TRACE_TAG); loop->magic = ~UV_LOOP_MAGIC; + uv_start_trace(UV_TRACE_TAG, "Release Write Lock"); uv_rwlock_wrunlock(&g_closed_uv_loop_rwlock); + uv_end_trace(UV_TRACE_TAG); time(&t2); UV_LOGI("uv_loop(%{public}zu) closed in %{public}zds", (size_t)loop, (ssize_t)(t2 - t1)); } diff --git a/src/unix/signal.c b/src/unix/signal.c index bc4206e6d864c8eed412d3c50e47438968465bfd..f15355f8a62515b13a3b956a83db953bacaf6e24 100644 --- a/src/unix/signal.c +++ b/src/unix/signal.c @@ -103,8 +103,14 @@ static void uv__signal_global_reinit(void) { if (uv__make_pipe(uv__signal_lock_pipefd, 0)) abort(); - if (uv__signal_unlock()) + if (uv__signal_unlock()) { +#ifdef OHOS_USE_DFX + UV_LOGF("errno is %d, uv__signal_lock_pipefd[1] is %d (%s:%s:%d)", errno, uv__signal_lock_pipefd[1], __FILE__, __func__, __LINE__); + return; +#else abort(); +#endif + } } @@ -148,14 +154,26 @@ static void uv__signal_block_and_lock(sigset_t* saved_sigmask) { if (pthread_sigmask(SIG_SETMASK, &new_mask, saved_sigmask)) abort(); - if (uv__signal_lock()) + if (uv__signal_lock()) { +#ifdef OHOS_USE_DFX + UV_LOGF("errno is %d, uv__signal_lock_pipefd[0] is %d (%s:%s:%d)", errno, uv__signal_lock_pipefd[0], __FILE__, __func__, __LINE__); + return; +#else abort(); +#endif + } } static void uv__signal_unlock_and_unblock(sigset_t* saved_sigmask) { - if (uv__signal_unlock()) + if (uv__signal_unlock()) { +#ifdef OHOS_USE_DFX + UV_LOGF("errno is %d, uv__signal_lock_pipefd[1] is %d (%s:%s:%d)", errno, uv__signal_lock_pipefd[1], __FILE__, __func__, __LINE__); + return; +#else abort(); +#endif + } if (pthread_sigmask(SIG_SETMASK, saved_sigmask, NULL)) abort(); @@ -461,8 +479,14 @@ static void uv__signal_event(uv_loop_t* loop, } /* Other errors really should never happen. */ - if (r == -1) + if (r == -1) { +#ifdef OHOS_USE_DFX + UV_LOGF("errno is %d, uv__signal_lock_pipefd[0] is %d (%s:%s:%d)", errno, uv__signal_lock_pipefd[0], __FILE__, __func__, __LINE__); + return; +#else abort(); +#endif + } bytes += r;