pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andreas Seltenreich <seltenreich@gmx.de>
To: pgsql-hackers@postgresql.org
To: Robert Haas <rhaas@postgresql.org>
To: Michael Paquier <michael.paquier@gmail.com>
Subject: [sqlsmith] Crash in pg_get_viewdef_name_ext()
Date: Sun, 07 Aug 2016 22:41:59 +0200
Message-ID: <87y448l3ag.fsf@credativ.de> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

Hi,

sqlsmith just triggered a crash in pg_get_viewdef_name_ext().  Looks
like commit 976b24fb4 failed to update this caller of
pg_get_viewdef_worker().  Backtrace below.  Patch attached.

regards,
Andreas

Program terminated with signal SIGSEGV, Segmentation fault.
(gdb) bt
#0  strlen () at ../sysdeps/x86_64/strlen.S:106
#1  0x00000000007cdf09 in cstring_to_text (s=s@entry=0x0) at varlena.c:152
#2  0x00000000007a3409 in string_to_text (str=0x0) at ruleutils.c:10083
#3  pg_get_viewdef_name_ext (fcinfo=<optimized out>) at ruleutils.c:681
#4  0x00000000005dfae2 in ExecMakeFunctionResultNoSets (fcache=0x403ed80, econtext=0x3fb0eb8, isNull=0x403e0a1 "", isDone=<optimized out>) at execQual.c:2041
[...]

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

Attachments:

ruleutils.patch (text/x-diff, 878B) download diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d68ca7a..3c3fce4 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -671,6 +671,7 @@ pg_get_viewdef_name_ext(PG_FUNCTION_ARGS) int prettyFlags; RangeVar *viewrel; Oid viewoid; + char *res; prettyFlags = pretty ? PRETTYFLAG_PAREN | PRETTYFLAG_INDENT : PRETTYFLAG_INDENT; @@ -678,7 +679,12 @@ pg_get_viewdef_name_ext(PG_FUNCTION_ARGS) viewrel = makeRangeVarFromNameList(textToQualifiedNameList(viewname)); viewoid = RangeVarGetRelid(viewrel, NoLock, false); - PG_RETURN_TEXT_P(string_to_text(pg_get_viewdef_worker(viewoid, prettyFlags, WRAP_COLUMN_DEFAULT))); + res = pg_get_viewdef_worker(viewoid, prettyFlags, WRAP_COLUMN_DEFAULT); + + if (res == NULL) + PG_RETURN_NULL(); + + PG_RETURN_TEXT_P(string_to_text(res)); } /*

view thread (3+ messages)  latest in thread

Message-ID: <87y448l3ag.fsf@credativ.de>
Permalink:  ../87y448l3ag.fsf@credativ.de/
Also on:    postgresql.org/message-id/87y448l3ag.fsf@credativ.de

 ·  · 

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-hackers@postgresql.org
  Cc: seltenreich@gmx.de, rhaas@postgresql.org, michael.paquier@gmail.com
  Subject: Re: [sqlsmith] Crash in pg_get_viewdef_name_ext()
  In-Reply-To: <87y448l3ag.fsf@credativ.de>
  References: <87y448l3ag.fsf@credativ.de>

* 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