public inbox for [email protected]
help / color / mirror / Atom feedFrom: =?utf-8?B?5p2o56OK?= <[email protected]>
To: =?utf-8?B?cGdzcWwtaGFja2Vycw==?= <[email protected]>
Subject: dlist_check: add check for nodes pointing to themselves
Date: Tue, 17 Mar 2026 20:56:15 +0800
Message-ID: <[email protected]> (raw)
Hi hackers,
I accidentally called the function dlist_push_head consecutively on the same node,
inserting it into a doubly linked list, which caused an infinite loop.
After adding the compile parameter -DILIST_DEBUG, an infinite loop occurred in the dlist_check function,
revealing that the next pointer of the current node was pointing to itself.
I am attempting to fix this issue with the following patch.
regards,
Lei Yang
Attachments:
[application/octet-stream] 0001-dlist_check-add-check-for-nodes-pointing-to-themselv.patch (1.0K, 2-0001-dlist_check-add-check-for-nodes-pointing-to-themselv.patch)
download | inline diff:
From 016a2c695a55f32a9df0e77ee9142c86c9a8f70d Mon Sep 17 00:00:00 2001
From: Lei Yang <[email protected]>
Date: Tue, 17 Mar 2026 20:51:28 +0800
Subject: [PATCH] dlist_check: add check for nodes pointing to themselves
---
src/backend/lib/ilist.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/backend/lib/ilist.c b/src/backend/lib/ilist.c
index d238858e24f..27dac796fd2 100644
--- a/src/backend/lib/ilist.c
+++ b/src/backend/lib/ilist.c
@@ -91,7 +91,8 @@ dlist_check(const dlist_head *head)
cur->next == NULL ||
cur->prev == NULL ||
cur->prev->next != cur ||
- cur->next->prev != cur)
+ cur->next->prev != cur ||
+ cur->next == cur)
elog(ERROR, "doubly linked list is corrupted");
}
@@ -102,7 +103,8 @@ dlist_check(const dlist_head *head)
cur->next == NULL ||
cur->prev == NULL ||
cur->prev->next != cur ||
- cur->next->prev != cur)
+ cur->next->prev != cur ||
+ cur->prev == cur)
elog(ERROR, "doubly linked list is corrupted");
}
}
--
2.34.1
view thread (2+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: dlist_check: add check for nodes pointing to themselves
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox