pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter Geoghegan <pg@heroku.com>
Cc: David Rowley <david.rowley@2ndquadrant.com>
Cc: Michael Paquier <michael.paquier@gmail.com>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Regina Obe <lr@pcorp.us>
Cc: PostgreSQL mailing lists <pgsql-bugs@postgresql.org>
Subject: Re: BUG #14344: string_agg(DISTINCT ..) crash
Date: Thu, 29 Sep 2016 11:40:46 -0400
Message-ID: <22270.1475163646@sss.pgh.pa.us> (raw)
In-Reply-To: <CAM3SWZQxeF5r4=U9-ikgn86Zun+LbcRfv6gQ0SWdWPQ5XVC6BQ@mail.gmail.com>
References: <20160929035538.20224.39628@wrigleys.postgresql.org>
	<12479.1475122250@sss.pgh.pa.us>
	<000001d21a09$dd22a9f0$9767fdd0$@pcorp.us>
	<CAB7nPqSF-xbTAraFJqbjZLin7AUOyfvMDwq1p=CEGSv3Y7Vf_w@mail.gmail.com>
	<CAKJS1f9mu3NpZaYhD2z5Cr1fTx=dYqXqi8BW1NCnfXF17E=Hvw@mail.gmail.com>
	<CAM3SWZSJyUvakbibG6cP_3gLVnVDaPKzHPjyh43Ap54Za9xDxg@mail.gmail.com>
	<CAKJS1f9V=OQb_JyZ8HmeLonJMhQFJe9PFzE77F2KTED1AqTXNw@mail.gmail.com>
	<CAM3SWZQWjMkRbH=D0Yp-i0Jaj2vmWupN-3E_f8keAh-7UQeRFw@mail.gmail.com>
	<CAKJS1f_4aw+Lfm=xUxfGQe-LQiNJc=OrfBYkg58By2Gn-aL5Zg@mail.gmail.com>
	<CAM3SWZRF5fuuBnk6jBtsjND6LY8g1xhX=3QKBwhq=bw7sG_BGw@mail.gmail.com>
	<CAM3SWZQxeF5r4=U9-ikgn86Zun+LbcRfv6gQ0SWdWPQ5XVC6BQ@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Peter Geoghegan <pg@heroku.com> writes:
> I see what the problem is. This use-after-free bug occurs because, for
> some reason, tuplesort_gettupleslot()'s contract was not updated by me
> alongside analogous routines like tuplesort_getindextuple() as part of
> the batch memory commit. This meant that at least one particular case
> (process_ordered_aggregate_multi() calls to tuplesort_gettupleslot(),
> with distinct columns) felt entitled to reuse some slot's tuple, a
> tuple located in memory managed by tuplesort.c as batch memory.

My immediate reaction to this is WTF.  It seems like you have completely
broken the expected contract of tuplesort_gettupleslot, which is that
it copies the data into caller-owned memory.  That cannot stand.  Even
if you are willing to hack all the core callers so that they no longer
expect that, you've probably broken --- subtly --- callers in extensions.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (30+ messages)  latest in thread

Message-ID: <22270.1475163646@sss.pgh.pa.us>
Permalink:  ../22270.1475163646@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/22270.1475163646@sss.pgh.pa.us

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pg@heroku.com, david.rowley@2ndquadrant.com, michael.paquier@gmail.com, robertmhaas@gmail.com, lr@pcorp.us
  Subject: Re: BUG #14344: string_agg(DISTINCT ..) crash
  In-Reply-To: <22270.1475163646@sss.pgh.pa.us>
  References: <20160929035538.20224.39628@wrigleys.postgresql.org> <12479.1475122250@sss.pgh.pa.us> <000001d21a09$dd22a9f0$9767fdd0$@pcorp.us> <CAB7nPqSF-xbTAraFJqbjZLin7AUOyfvMDwq1p=CEGSv3Y7Vf_w@mail.gmail.com> <CAKJS1f9mu3NpZaYhD2z5Cr1fTx=dYqXqi8BW1NCnfXF17E=Hvw@mail.gmail.com> <CAM3SWZSJyUvakbibG6cP_3gLVnVDaPKzHPjyh43Ap54Za9xDxg@mail.gmail.com> <CAKJS1f9V=OQb_JyZ8HmeLonJMhQFJe9PFzE77F2KTED1AqTXNw@mail.gmail.com> <CAM3SWZQWjMkRbH=D0Yp-i0Jaj2vmWupN-3E_f8keAh-7UQeRFw@mail.gmail.com> <CAKJS1f_4aw+Lfm=xUxfGQe-LQiNJc=OrfBYkg58By2Gn-aL5Zg@mail.gmail.com> <CAM3SWZRF5fuuBnk6jBtsjND6LY8g1xhX=3QKBwhq=bw7sG_BGw@mail.gmail.com> <CAM3SWZQxeF5r4=U9-ikgn86Zun+LbcRfv6gQ0SWdWPQ5XVC6BQ@mail.gmail.com> <22270.1475163646@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox