pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: marcos.castedo@anachronics.com
To: pgsql-bugs@postgresql.org
Subject: BUG #14472: Backend crash​e​​s​ on array append for domains of array with constraint check
Date: Wed, 21 Dec 2016 21:47:44 +0000
Message-ID: <20161221214744.25622.71454@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

The following bug has been logged on the website:

Bug reference:      14472
Logged by:          Marcos Castedo
Email address:      marcos.castedo@anachronics.com
PostgreSQL version: 9.6.1
Operating system:   Debian stretch
Description:        

We have an issue related with bug #14414 reported on PostgreSQL 9.6.1.

Test case:

BEGIN;

CREATE OR REPLACE FUNCTION x_domain_test_check(integer[])
RETURNS boolean AS $$
BEGIN
	RETURN true;
END;
$$ LANGUAGE plpgsql IMMUTABLE;

CREATE DOMAIN x_domain_test AS integer[]
CHECK(x_domain_test_check(value));

DO $$
DECLARE
	v_test x_domain_test;
BEGIN
	v_test := '{}'::x_domain_test;
	v_test := v_test || 1; --SEGV on 9.6.1 with #14414 fixed
END;
$$;

ROLLBACK;

With 9.6.1 vanilla the test case fai​​l​s​ with SPI_connect error
(SPI_ERROR_CONNECT), but with ​the following patch applied (take​n​ from
#14414​'s​ fix on github) the backend crash​e​​s​ with "Segmentation
fault"​​.

--- postgresql-9.6.1/src/pl/plpgsql/src/pl_exec.c	2016-10-24
17:08:51.000000000 -0300
+++ postgresql-9.6.1-1/src/pl/plpgsql/src/pl_exec.c	2016-12-21
12:38:39.176980654 -0300
@@ -6102,6 +6102,8 @@ exec_cast_value(PLpgSQL_execstate *estat
 			ExprContext *econtext = estate->eval_econtext;
 			MemoryContext oldcontext;
 
+			SPI_push();
+
 			oldcontext = MemoryContextSwitchTo(econtext->ecxt_per_tuple_memory);
 
 			econtext->caseValue_datum = value;
@@ -6115,6 +6117,8 @@ exec_cast_value(PLpgSQL_execstate *estat
 			cast_entry->cast_in_use = false;
 
 			MemoryContextSwitchTo(oldcontext);
+
+			SPI_pop();
 		}
 	}



-- 
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 (2+ messages)  latest in thread

Message-ID: <20161221214744.25622.71454@wrigleys.postgresql.org>
Permalink:  ../20161221214744.25622.71454@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/20161221214744.25622.71454@wrigleys.postgresql.org

 · 

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: marcos.castedo@anachronics.com
  Subject: Re: BUG #14472: Backend crash​e​​s​ on array append for domains of array with constraint check
  In-Reply-To: <20161221214744.25622.71454@wrigleys.postgresql.org>
  References: <20161221214744.25622.71454@wrigleys.postgresql.org>

* 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