pg.ddx.io pgsql-hackers@postgresql.org mailing list archive
help / color / mirror / Atom feed[sqlsmith] Crash in pg_get_viewdef_name_ext()
3+ messages / 3 participants
[nested] [flat]
* [sqlsmith] Crash in pg_get_viewdef_name_ext()
@ 2016-08-07 20:41 Andreas Seltenreich <seltenreich@gmx.de>
2016-08-07 21:57 ` Re: [sqlsmith] Crash in pg_get_viewdef_name_ext() Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 3+ messages in thread
From: Andreas Seltenreich @ 2016-08-07 20:41 UTC (permalink / raw)
To: pgsql-hackers; Robert Haas <rhaas@postgresql.org>; Michael Paquier <michael.paquier@gmail.com>
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));
}
/*
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: [sqlsmith] Crash in pg_get_viewdef_name_ext()
2016-08-07 20:41 [sqlsmith] Crash in pg_get_viewdef_name_ext() Andreas Seltenreich <seltenreich@gmx.de>
@ 2016-08-07 21:57 ` Tom Lane <tgl@sss.pgh.pa.us>
2016-08-07 23:43 ` Re: [sqlsmith] Crash in pg_get_viewdef_name_ext() Michael Paquier <michael.paquier@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Tom Lane @ 2016-08-07 21:57 UTC (permalink / raw)
To: Andreas Seltenreich <seltenreich@gmx.de>; +Cc: pgsql-hackers; Robert Haas <rhaas@postgresql.org>; Michael Paquier <michael.paquier@gmail.com>
Andreas Seltenreich <seltenreich@gmx.de> writes:
> 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.
Pushed, thanks.
(For the record, you can trigger this by passing a name that is
a valid relation, but not a view.)
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: [sqlsmith] Crash in pg_get_viewdef_name_ext()
2016-08-07 20:41 [sqlsmith] Crash in pg_get_viewdef_name_ext() Andreas Seltenreich <seltenreich@gmx.de>
2016-08-07 21:57 ` Re: [sqlsmith] Crash in pg_get_viewdef_name_ext() Tom Lane <tgl@sss.pgh.pa.us>
@ 2016-08-07 23:43 ` Michael Paquier <michael.paquier@gmail.com>
0 siblings, 0 replies; 3+ messages in thread
From: Michael Paquier @ 2016-08-07 23:43 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Andreas Seltenreich <seltenreich@gmx.de>; pgsql-hackers; Robert Haas <rhaas@postgresql.org>
On Mon, Aug 8, 2016 at 6:57 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Andreas Seltenreich <seltenreich@gmx.de> writes:
>> 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.
>
> Pushed, thanks.
>
> (For the record, you can trigger this by passing a name that is
> a valid relation, but not a view.)
Oops. Thanks for the fix!
--
Michael
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2016-08-07 23:43 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-08-07 20:41 [sqlsmith] Crash in pg_get_viewdef_name_ext() Andreas Seltenreich <seltenreich@gmx.de>
2016-08-07 21:57 ` Tom Lane <tgl@sss.pgh.pa.us>
2016-08-07 23:43 ` Michael Paquier <michael.paquier@gmail.com>
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