Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ggN0f-00010f-QT for pgsql-bugs@arkaria.postgresql.org; Mon, 07 Jan 2019 04:59:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ggN0e-0007Kw-7B for pgsql-bugs@arkaria.postgresql.org; Mon, 07 Jan 2019 04:59:32 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ggN0c-0007Kp-HN for pgsql-bugs@lists.postgresql.org; Mon, 07 Jan 2019 04:59:32 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ggN0X-0001G4-8Q for pgsql-bugs@lists.postgresql.org; Mon, 07 Jan 2019 04:59:29 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 9FDE62217A; Sun, 6 Jan 2019 23:59:23 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Sun, 06 Jan 2019 23:59:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=/COTxEYXK9hx3V0wMeAXrQTmlLL rp4fGoA+tDy/prJM=; b=gVvFoNFEGwGHYMWCwzsJ5Q5MupXM2ZjQc7qQ9xIbqZ1 iKVgAf7W188A4KuTGN8UAb26aeMw486dEHtAvgQFebSZdc/PJB2R6YOPfi+BItX+ tkTitGycIJsjFt9PStV/MjW8eeUiAphbtJWjQCIdbmT1vBIpWvX4Sl5h97mopGqF rq+CxHUHDFti3oxBC2Q3/rXjoEAOPYTTyXNuRAR+W4Zn1QC3XojLgxlyzO6mltAb zxgH8iA8ZR2dO2VQ8yM7t56Uu6yraDbyFdb7v0x/4b99Ix4OC4TSww5rYF8Nm4kq zfsWlpLchNYYBRjzJ/w0f+B5FlHHpsqGxAw6lKO4b1A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=/COTxE YXK9hx3V0wMeAXrQTmlLLrp4fGoA+tDy/prJM=; b=t+NWWgzdJs7J7bacEfA6lp FLUrbBcFXZGA5nB/aQvrRxuI5EAhYgnKIDlTKElqRBgl5BfiJT/kEwaiwuR5fTRL +xIGre6VMnrx/mWBOIvNRvntKGnDTogbzDxp9xnN7MZH/kDduPVNhQjAOUVvcNT4 FnWDRdzN7Vhw1APPAGYEtJvvOmrUhnmM5P9PQ9Dm0UbHiOUDY7kyVPvUt72Wdtxd 8xs/VOSNScfzRpTeL64vaD4M0uxhm1DGM1O6LF9+8uu6+t1d7g9N66vVlkFSXZDP GsOMeD+g+281F2RE7DIvgpK6VgHRzxBiSLTJHc86qjelOD+iHhjOyZIzM0UNcRSA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtledrvdeigdektdculddtuddrgedtkedrtddtmd cutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthen uceurghilhhouhhtmecufedttdenucgfrhhlucfvnfffucdlfeehmdenucfjughrpeffhf fvuffkfhggtggujgesghdtreertddtvdenucfhrhhomhepofhitghhrggvlhcurfgrqhhu ihgvrhcuoehmihgthhgrvghlsehprghquhhivghrrdighiiiqeenucffohhmrghinhepph hoshhtghhrrdgvshenucfkphepiedurddvudehrddufeejrdduiedvnecurfgrrhgrmhep mhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiiinecuvehluhhsth gvrhfuihiivgeptd X-ME-Proxy: Received: from paquier.xyz (c137162.net61215.cablenet.ne.jp [61.215.137.162]) by mail.messagingengine.com (Postfix) with ESMTPA id 389ACE4366; Sun, 6 Jan 2019 23:59:21 -0500 (EST) Date: Mon, 7 Jan 2019 13:59:18 +0900 From: Michael Paquier To: gregk@stoddarts.com.au, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15578: Executing json_populate_recordset with an empty array causes a segmentation fault Message-ID: <20190107045918.GC22498@paquier.xyz> References: <15578-832c854e58dde50c@postgresql.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="jTMWTj4UTAEmbWeb" Content-Disposition: inline In-Reply-To: <15578-832c854e58dde50c@postgresql.org> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --jTMWTj4UTAEmbWeb Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jan 07, 2019 at 03:52:26AM +0000, PG Bug reporting form wrote: > When executing json_populate_recordset/jsonb_populate_recordset with an > empty array, a segmentation fault occurs and the server process is > terminated. The issue occurs regardless of the type used. In previous > versions this would return null. This has been already fixed by a recent commit, which will be released with 11.2 in the next round of minor releases (see also 595220a which applies to REL_11_STABLE): commit: eba2ce17121f198316d050e71d8bd049a43783ba author: Tom Lane date: Thu, 22 Nov 2018 15:14:01 -0500 committer: Tom Lane date: Thu, 22 Nov 2018 15:14:01 -0500 Fix another crash in json{b}_populate_recordset and json{b}_to_recordset. populate_recordset_worker() failed to consider the possibility that the supplied JSON data contains no rows, so that update_cached_tupdesc never got called. This led to a null-pointer dereference since commit 9a5e8ed28; before that it led to a bogus "set-valued function called in context that cannot accept a set" error. Fix by forcing the update to happen. Per bug #15514. Back-patch to v11 as 9a5e8ed28 was. (If we were excited= =20 about the bogus error, we could perhaps go back further, but it'd take more work to figure out how to fix it in older branches. Given the lack of field complaints about that aspect, I'm not excited.) Discussion: https://postgr.es/m/15514-59d5b4c4065b178b@postgresql.org -- Michael --jTMWTj4UTAEmbWeb Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAlwy3KYACgkQnvQgOdby QH1cUg/7BM2Vhk0kKGO0g4g8a+6Ep//AacBCSc96Iibdqziay0KY0RM4A1a/IhY0 kd8BkA+a4epmOCgqoZTjsM20fTXXvyJ71cmyIpiSNys5+iXORsdmAAlFHGnf71Tb zH1HJndzpPjtXrTqmEIANcnBfjlXn7W56vYqR/XyF2qIYyFnh5hkS8TO33Drg8Sz +mVeTK1wbeNK1q1F7Ko2MP5hm0o34Lr0+5OfhuuJgaU7et34lbHIw5QvIy0uDKNU aOfW9wR6yyixMZl4ovMXBwnLTAdKqDhaQAm4wFug7MDhPAX1HE1YmANng3ulgtDx /ApwKoLxp+kK5N3QRhjWET87dcazwYBoS0ZElftAipcREQXAD0Ac/2JeK7AyLzEt v6jUweZaC6i9vSFr0p1zNazksxg0tc+gIbthJLqf6s61xOPezosqFYHC+t5uNipK LINAXZlO3z+6zFdn+c86BzIIlphXTu+UbqEKCh8b/Ysst0T1Ipwc906iH+/Ev+9P t7srYMhJee2Nlbge9Tpyu/EZNFdCSy9uG2CRDZ93iNhBTbAFrcrecflhO0EP1Wby C0QhSqI1z2TKnjrO5Oit1t374i2l2whAU8hw+lZRfkMatwpIJDEnShfzpaJgVu9B etrZmfWWYm3yu1HodZBKhNhpqF7ctG4L2KGcpRrFZZ8Ro78+Cgk= =CdIT -----END PGP SIGNATURE----- --jTMWTj4UTAEmbWeb--