Re: pgsql: Fix fat fingering in 22cb6d28950

From: Mahendra Singh Thalor <mahi6run(at)gmail(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: Re: pgsql: Fix fat fingering in 22cb6d28950
Date: 2025-04-11 19:24:02
Message-ID: CAKYtNAoQaLLreOzwvad2HBJUrCgRugxpUNKnF5Obzp0HhoGH8w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

On Fri, 11 Apr 2025 at 04:38, Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:
>
> Fix fat fingering in 22cb6d28950
>
> Per Rainier Vilela
>
> Branch
> ------
> master
>
> Details
> -------
>
https://git.postgresql.org/pg/commitdiff/39729ec01d25dbe12e0dd8322c68f242650235c9
>
> Modified Files
> --------------
> src/bin/pg_dump/pg_restore.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>

Hi,
This seems not a proper fix, rather this is adding a segfault.

Program received signal SIGABRT, Aborted.
0x0000153dc3002acf in raise () from /lib64/libc.so.6
(gdb) bt
#0 0x0000153dc3002acf in raise () from /lib64/libc.so.6
#1 0x0000153dc2fd5ea5 in abort () from /lib64/libc.so.6
#2 0x0000153dc3043cc7 in __libc_message () from /lib64/libc.so.6
#3 0x0000153dc304afcc in malloc_printerr () from /lib64/libc.so.6
#4 0x0000153dc304d050 in _int_free () from /lib64/libc.so.6
#5 0x0000000000426b74 in pg_free (ptr=0x7fff48145ac0) at fe_memutils.c:107
#6 0x0000000000426bef in pfree (pointer=0x7fff48145ac0) at
fe_memutils.c:135
#7 0x000000000042354f in destroyStringInfo (str=0x7fff48145ac0) at
stringinfo.c:415
#8 0x00000000004055c6 in read_one_statement (inBuf=0x7fff48145b30,
pfile=0x1165ec0) at pg_restore.c:909
#9 0x0000000000406339 in process_global_sql_commands (conn=0x115c9d0,
dumpdirpath=0x7fff481491d3 "x1", outfile=0x0) at pg_restore.c:1321
#10 0x0000000000405d43 in restore_all_databases (conn=0x115c9d0,
dumpdirpath=0x7fff481491d3 "x1", db_exclude_patterns=..., opts=0x115c750,
numWorkers=10) at pg_restore.c:1154
#11 0x0000000000404925 in main (argc=7, argv=0x7fff48147448) at
pg_restore.c:555

* To destroy a StringInfo, pfree() the data buffer, and then pfree() the
> * StringInfoData if it was palloc'd. For StringInfos created with
> * makeStringInfo(), destroyStringInfo() is provided for this purpose.
> * However, if the StringInfo was initialized using
> initReadOnlyStringInfo()
> * then the caller will need to consider if it is safe to pfree the data
> * buffer.

Here, we are passing &q, but we can't free this by destroyStringInfo(&q);

*Fix*: pg_free(q.data)

--
Thanks and Regards
Mahendra Singh Thalor
EnterpriseDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Daniel Gustafsson 2025-04-11 20:22:02 pgsql: Fix recently introduced typos
Previous Message Nathan Bossart 2025-04-11 15:06:04 pgsql: Add missing space in pg_restore documentation.