diff --git a/BUILD.gn b/BUILD.gn index c8d59957ca19a6313aa279a5b37d171d549bd785..9d17a3192e8a05ebfd8e08f7e6ce051c8c7a3eb6 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -350,9 +350,6 @@ if (defined(ohos_lite)) { } ohos_shared_library("uv") { deps = [ ":libuv_source" ] - if (is_linux || is_ohos) { - ldflags = [ "-Wl,--exclude-libs=ALL" ] - } external_deps = [ "hilog:libhilog" ] public_configs = [ ":libuv_config" ] subsystem_name = "thirdparty" diff --git a/src/heap-inl.h b/src/heap-inl.h index 1e2ed60e09417c481f07a51c59d9866baa7ebe81..bc82885e4ec39fd88493af528c0abca5a4701075 100644 --- a/src/heap-inl.h +++ b/src/heap-inl.h @@ -17,6 +17,8 @@ #define UV_SRC_HEAP_H_ #include /* NULL */ +#include "uv_log.h" + #if defined(__GNUC__) # define HEAP_EXPORT(declaration) __attribute__((unused)) static declaration @@ -137,6 +139,12 @@ HEAP_EXPORT(void heap_insert(struct heap* heap, /* Insert the new node. */ newnode->parent = *parent; +#ifdef USE_OHOS_DFX + if (child == NULL || newnode == NULL) { + UV_LOGF("Child is NULL, this may be due to multi-threaded calls."); + return; + } +#endif *child = newnode; heap->nelts += 1; @@ -177,13 +185,19 @@ HEAP_EXPORT(void heap_remove(struct heap* heap, path >>= 1; k -= 1; } - - heap->nelts -= 1; - + /* Unlink the max node. */ child = *max; *max = NULL; +#ifdef USE_OHOS_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) {