public inbox for [email protected]  
help / color / mirror / Atom feed
From: [email protected] <[email protected]>
To: yanglei <[email protected]>
Cc: pgsql-hackers <[email protected]>
Subject: Re: dlist_check: add check for nodes pointing to themselves
Date: Wed, 8 Apr 2026 23:46:59 +0800
Message-ID: <[email protected]> (raw)
References: <[email protected]>

Currently, postgresql will enter an infinite loop when calling dlist_push_head the second time. 
After applying this patch, it will report ERROR: doubly linked list is corrupted.

test case:
./configure --enable-debug CFLAGS='-O0 -DILIST_DEBUG' --enable-cassert

PG_FUNCTION_INFO_V1(test_dlist);
Datum
test_dlist(PG_FUNCTION_ARGS)
{
dlist_head head;
dlist_node *n;

n = palloc0(sizeof(dlist_node));
dlist_init(&head);
dlist_push_head(&head, n);
dlist_push_head(&head, n);

PG_RETURN_NULL();
}





regards,
Lei Yang
 
From: 杨磊
Date: 2026-03-17 20:56
To: pgsql-hackers
Subject: dlist_check: add check for nodes pointing to themselves
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


view thread (2+ messages)

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], [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