[PATCH] Fix leaked hash scans in pg_listening_channels()
Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.
You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:
docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t254268psql -h localhost -U postgresBuilt from patchset v1 (message #1), October 22, 2026 at 06:18 AM.
Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:
git clone --branch t254268_1 https://github.com/hackorum-dev/postgres.gitIn a checkout you already have, add the fork once:
git remote add hackorum https://github.com/hackorum-dev/postgres.gitthen, for this patchset and every later one:
git fetch hackorum t254268_1 && git checkout t254268_1Patchset v1 (message #1) is on t254268_1
Hi hackers,
I found a hash scan leak in pg_listening_channels(), introduced by
282b1cde9d.
LISTEN ch;
SELECT pg_listening_channels() LIMIT 1;
The SELECT emits a leak warning in the server logs.
Repeated early exits can exhaust the hash scan limit and cause a
server crash.
Attached patch uses InitMaterializedSRF() to complete the scan
before returning rows, following 257c8231bf.
/Joel
On Mon, Oct 19, 2026 at 2:42 PM Joel Jacobson <joel@compiler.org> wrote:
Attached patch uses InitMaterializedSRF() to complete the scan
before returning rows, following 257c8231bf.
Hi Joel,
I reviewed the attached patch on master with assertions enabled. Before the
fix,
repeated target-list calls under `LIMIT` in one transaction cause
a backend crash with `PANIC: ERRORDATA_STACK_SIZE exceeded`. With the patch,
the same workload completes without warnings or errors.
The materialization approach follows the SRF guidance in `funcapi.h` and
looks good to me.
Thanks,
Sho
--
=======================================
*Sho Ito (Sean)*
E-mail: i.sho.0628@gmail.com
LinkedIn: *https://www.linkedin.com/in/sho-ito-0628/
<https://www.linkedin.com/in/sho-ito-0628/>*
GitHub: https://github.com/sean0628/
=======================================
On Wed, Oct 21, 2026, at 09:19, Sho Ito wrote:
On Mon, Oct 19, 2026 at 2:42 PM Joel Jacobson <joel@compiler.org> wrote:
Attached patch uses InitMaterializedSRF() to complete the scan
before returning rows, following 257c8231bf.Hi Joel,
I reviewed the attached patch on master with assertions enabled. Before the fix,
repeated target-list calls under `LIMIT` in one transaction cause
a backend crash with `PANIC: ERRORDATA_STACK_SIZE exceeded`. With the patch,
the same workload completes without warnings or errors.The materialization approach follows the SRF guidance in `funcapi.h`
and looks good to me.
Thanks for review.
Here is the commitfest entry:
https://commitfest.postgresql.org/patch/7481/
If you think it's Ready for Committer
you can update the status there.
Thanks,
Sho--
=======================================
*Sho Ito (Sean)*E-mail: i.sho.0628@gmail.com
LinkedIn: _https://www.linkedin.com/in/sho-ito-0628/_
GitHub: https://github.com/sean0628/
=======================================
--
Kind regards,
Joel
On Thu, Oct 22, 2026 at 3:56 AM Joel Jacobson <joel@compiler.org> wrote:
If you think it's Ready for Committer
you can update the status there.
Updated. Thanks!
Sho
--
=======================================
*Sho Ito (Sean)*
E-mail: i.sho.0628@gmail.com
LinkedIn: *https://www.linkedin.com/in/sho-ito-0628/
<https://www.linkedin.com/in/sho-ito-0628/>*
GitHub: https://github.com/sean0628/
=======================================