[postgis-devel] st_asflatgeobuf detoast crash
Julien Rouhaud
rjuju123 at gmail.com
Sat Jun 18 08:41:26 PDT 2022
Hi,
On Sat, Jun 18, 2022 at 06:52:10AM -0500, Justin Pryzby wrote:
> An instance running pg15beta1 crashed while running one of sqlsmith's appalling
> queries. I reproduced with this, simplified query:
>
> select st_asflatgeobuf(row(1), false, '')
> over () from information_schema.table_privileges
>
> Program terminated with signal 11, Segmentation fault.
> #0 pg_detoast_datum_copy (datum=0x514) at fmgr.c:1719
All versions of st_asflatgeobuf have the same problem, so you can reduce the
reproducer to:
select st_asflatgeobuf(row(1)) from pg_class;
AFAICT, inspect_table() doesn't check that a geometry column was indeed found,
leading to the problem.
Some like that fixes the crash for me:
diff --git a/postgis/flatgeobuf.c b/postgis/flatgeobuf.c
index 1b502e546..545442f31 100644
--- a/postgis/flatgeobuf.c
+++ b/postgis/flatgeobuf.c
@@ -110,6 +110,9 @@ static void inspect_table(struct flatgeobuf_agg_ctx *ctx)
columns_size++;
}
+ if (!geom_found)
+ elog(ERROR, "no geom column found");
+
if (columns_size > 0) {
ctx->ctx->columns = columns;
ctx->ctx->columns_size = columns_size;
More information about the postgis-devel
mailing list