Re: BUG #17879: ERROR: unrecognized node type: 2139062143 - Mailing list pgsql-bugs

From David Rowley
Subject Re: BUG #17879: ERROR: unrecognized node type: 2139062143
Date
Msg-id CAApHDvrFOjY9-6=mqx4r9YO7HoXdZ_5jsuiS0FFGfWC8YrJ7yA@mail.gmail.com
Whole thread Raw
In response to BUG #17879: ERROR: unrecognized node type: 2139062143  (PG Bug reporting form <noreply@postgresql.org>)
Responses Re: BUG #17879: ERROR: unrecognized node type: 2139062143  (David Rowley <dgrowleyml@gmail.com>)
List pgsql-bugs
On Thu, 30 Mar 2023 at 22:21, PG Bug reporting form
<noreply@postgresql.org> wrote:
> CREATE TABLE mytable1(id INT GENERATED ALWAYS AS IDENTITY (SEQUENCE NAME
> test_seq));

> We have identified the root cause as follows:
> In the generateSerialExtraStmts function, the memory space for the seqoption
> list has been freed, but the options member of the Constraint still points
> to that memory address, which caused an error during the copyObject
> operation in the EventTriggerCollectSimpleCommand function.

Thank you for the detailed report and reproducer.

The problem seems to be down to generateSerialExtraStmts() deleting a
cell out of the given seqoptions resulting in that becoming an empty
list, but the calling function does not have its list pointer set to
NIL.

I see a few ways to fix; 1) always make a list_copy() of the list
before calling generateSerialExtraStmts(), or; 2) make a copy of the
list inside generateSerialExtraStmts() unconditionally, or 3) at the
very least, just make a copy before calling list_delete_nth_cell().

#1 and #2 might be a bit more effort than is really required, so the
attached does #3.

David

Attachment

pgsql-bugs by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: BUG #17877: Referencing a system column in a foreign key leads to incorrect memory access
Next
From: Tom Lane
Date:
Subject: Re: BUG #16329: Valgrind detects an invalid read when building a gist index with buffering