From 8842b9343c868d8857242cb6647f0dadaf550c96 Mon Sep 17 00:00:00 2001 From: liaoxingxing Date: Fri, 9 Aug 2024 17:47:25 +0800 Subject: [PATCH 1/5] make sure timer child not null Signed-off-by: liaoxingxing --- src/heap-inl.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/heap-inl.h b/src/heap-inl.h index 939a523..9b6f2e8 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 @@ -135,6 +137,13 @@ HEAP_EXPORT(void heap_insert(struct heap* heap, k -= 1; } +#ifdef USE_OHOS_DFX + if (*child == NULL) { + UV_LOGF("Child is NULL, this may be due to multi-threaded calls."); + return; + } +#endif + /* Insert the new node. */ newnode->parent = *parent; *child = newnode; @@ -178,8 +187,13 @@ HEAP_EXPORT(void heap_remove(struct heap* heap, k -= 1; } +#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; - /* Unlink the max node. */ child = *max; *max = NULL; -- Gitee From c470c90c3538b123150791bc7d358def7408dca4 Mon Sep 17 00:00:00 2001 From: liaoxingxing Date: Fri, 9 Aug 2024 17:50:26 +0800 Subject: [PATCH 2/5] make sure timer child not null Signed-off-by: liaoxingxing --- src/heap-inl.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/heap-inl.h b/src/heap-inl.h index 9b6f2e8..e4b2fbd 100644 --- a/src/heap-inl.h +++ b/src/heap-inl.h @@ -187,6 +187,10 @@ HEAP_EXPORT(void heap_remove(struct heap* heap, k -= 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."); @@ -194,9 +198,6 @@ HEAP_EXPORT(void heap_remove(struct heap* heap, } #endif heap->nelts -= 1; - /* Unlink the max node. */ - child = *max; - *max = NULL; if (child == node) { /* We're removing either the max or the last node in the tree. */ -- Gitee From 0814c3389fc6ac5c63bdb42d68a0d5b14d2f4d4a Mon Sep 17 00:00:00 2001 From: liaoxingxing Date: Fri, 9 Aug 2024 22:42:27 +0800 Subject: [PATCH 3/5] make sure timer child not null Signed-off-by: liaoxingxing --- src/heap-inl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/heap-inl.h b/src/heap-inl.h index e4b2fbd..b26e101 100644 --- a/src/heap-inl.h +++ b/src/heap-inl.h @@ -138,7 +138,7 @@ HEAP_EXPORT(void heap_insert(struct heap* heap, } #ifdef USE_OHOS_DFX - if (*child == NULL) { + if (newnode == NULL) { UV_LOGF("Child is NULL, this may be due to multi-threaded calls."); return; } -- Gitee From a6f7b337b4c80d23bf758ab5aac810c3059e8abd Mon Sep 17 00:00:00 2001 From: liaoxingxing Date: Fri, 9 Aug 2024 22:51:01 +0800 Subject: [PATCH 4/5] make sure timer child not null Signed-off-by: liaoxingxing --- src/heap-inl.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/heap-inl.h b/src/heap-inl.h index b26e101..cb32e6a 100644 --- a/src/heap-inl.h +++ b/src/heap-inl.h @@ -137,15 +137,14 @@ HEAP_EXPORT(void heap_insert(struct heap* heap, k -= 1; } + /* Insert the new node. */ + newnode->parent = *parent; #ifdef USE_OHOS_DFX if (newnode == NULL) { UV_LOGF("Child is NULL, this may be due to multi-threaded calls."); return; } #endif - - /* Insert the new node. */ - newnode->parent = *parent; *child = newnode; heap->nelts += 1; -- Gitee From 8da342af5c26c2f2f4a992748701d2d16e9124f1 Mon Sep 17 00:00:00 2001 From: liaoxingxing Date: Fri, 9 Aug 2024 22:51:58 +0800 Subject: [PATCH 5/5] make sure timer child not null Signed-off-by: liaoxingxing --- src/heap-inl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/heap-inl.h b/src/heap-inl.h index cb32e6a..bc82885 100644 --- a/src/heap-inl.h +++ b/src/heap-inl.h @@ -140,7 +140,7 @@ HEAP_EXPORT(void heap_insert(struct heap* heap, /* Insert the new node. */ newnode->parent = *parent; #ifdef USE_OHOS_DFX - if (newnode == NULL) { + if (child == NULL || newnode == NULL) { UV_LOGF("Child is NULL, this may be due to multi-threaded calls."); return; } -- Gitee