| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Alexander Lakhin <exclusion(at)gmail(dot)com> |
| Cc: | Richard Guo <guofenglinux(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Álvaro Herrera <alvherre(at)kurilemu(dot)de>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: Why our Valgrind reports suck |
| Date: | 2026-06-10 20:41:29 |
| Message-ID: | 1421978.1781124089@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Alexander Lakhin <exclusion(at)gmail(dot)com> writes:
> Could you please look at an issue apparently related to the change shown
> above? This simple modification:
> ...
> (That its, the error message added in 26ec6b594, triggers double pfree and
> segfault now.)
Hah, nice one. Apparently the "detach the queue" path in
mq_putmessage() has never ever been tested, because it
contains a double pfree, and this fixes it:
diff --git a/src/backend/libpq/pqmq.c b/src/backend/libpq/pqmq.c
index 21ce180c78d..d038a9da515 100644
--- a/src/backend/libpq/pqmq.c
+++ b/src/backend/libpq/pqmq.c
@@ -140,7 +140,6 @@ mq_putmessage(char msgtype, const char *s, size_t len)
if (pq_mq_handle != NULL)
{
shm_mq_detach(pq_mq_handle);
- pfree(pq_mq_handle);
pq_mq_handle = NULL;
}
return EOF;
The necessity of this can be observed by noting that the last
step in shm_mq_detach() is to pfree the pointer it was handed.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Zsolt Parragi | 2026-06-10 20:43:41 | Re: [PATCH] Add pg_get_table_ddl() to reconstruct CREATE TABLE statements |
| Previous Message | Andres Freund | 2026-06-10 20:29:33 | Re: Heads Up: cirrus-ci is shutting down June 1st |