SEGFAULT in CREATE EXTENSION related pg_init_privs - Mailing list pgsql-hackers

From Pavel Stehule
Subject SEGFAULT in CREATE EXTENSION related pg_init_privs
Date
Msg-id CAFj8pRDspAVLrAgd3LEhcO0hXMdveE3P04LCcvp=_2HvfHnT1Q@mail.gmail.com
Whole thread Raw
Responses Re: SEGFAULT in CREATE EXTENSION related pg_init_privs  (Peter Geoghegan <pg@bowt.ie>)
Re: SEGFAULT in CREATE EXTENSION related pg_init_privs  (Stephen Frost <sfrost@snowman.net>)
List pgsql-hackers
Hi

I am trying to prepare orafce for PostgreSQL 9.6.

I can successfully compile this extension, but the statement CREATE EXTENSION fails on segfault

 (gdb) bt
#0  heap_deform_tuple (tuple=tuple@entry=0x1d87e90, tupleDesc=tupleDesc@entry=0x7f1dab9525b0, values=values@entry=0x1d87a28,
    isnull=isnull@entry=0x1d882d8 "\177\177\177\177\177~\177\177") at heaptuple.c:881
#1  0x0000000000477eda in heap_modify_tuple (tuple=tuple@entry=0x1d87e90, tupleDesc=0x7f1dab9525b0,
    replValues=replValues@entry=0x7ffc5e4076b0, replIsnull=replIsnull@entry=0x7ffc5e407690 "",
    doReplace=doReplace@entry=0x7ffc5e4076a0 "") at heaptuple.c:817
#2  0x0000000000516ddb in recordExtensionInitPriv (objoid=objoid@entry=16471, classoid=classoid@entry=1259,
    objsubid=objsubid@entry=0, new_acl=new_acl@entry=0x1d879d0) at aclchk.c:5305
#3  0x0000000000519550 in recordExtensionInitPriv (new_acl=0x1d879d0, objsubid=0, classoid=1259, objoid=16471) at aclchk.c:5262
#4  ExecGrant_Relation (istmt=0x7ffc5e407bc0) at aclchk.c:1965
#5  0x000000000051a325 in ExecGrantStmt_oids (istmt=istmt@entry=0x7ffc5e407bc0) at aclchk.c:564
#6  0x000000000051bdff in ExecuteGrantStmt (stmt=stmt@entry=0x1b719f8) at aclchk.c:549
#7  0x00000000006f88f9 in ProcessUtilitySlow (parsetree=parsetree@entry=0x1b719f8,
    queryString=queryString@entry=0x1ae30d8 "/* contrib/orafce--3.2.sql */\n\n-- complain if script is sourced in psql, rather than via CREATE EXTENSION\n\n\nCREATE FUNCTION pg_catalog.trunc(value date, fmt text)\nRETURNS date\nAS '$libdir/orafce','ora"...,
    context=context@entry=PROCESS_UTILITY_QUERY, params=params@entry=0x0, completionTag=completionTag@entry=0x0,
    dest=0xc7ec40 <donothingDR>) at utility.c:1514
#8  0x00000000006f76bb in standard_ProcessUtility (parsetree=0x1b719f8,
    queryString=0x1ae30d8 "/* contrib/orafce--3.2.sql */\n\n-- complain if script is sourced in psql, rather than via CREATE EXTENSION\n\n\nCREATE FUNCTION pg_catalog.trunc(value date, fmt text)\nRETURNS date\nAS '$libdir/orafce','ora"...,
    context=PROCESS_UTILITY_QUERY, params=0x0, dest=0xc7ec40 <donothingDR>, completionTag=0x0) at utility.c:907
#9  0x000000000058ed9d in execute_sql_string (filename=0x1a8b0a8 "/usr/local/pgsql/share/extension/orafce--3.3.sql",
    sql=0x1ae30d8 "/* contrib/orafce--3.2.sql */\n\n-- complain if script is sourced in psql, rather than via CREATE EXTENSION\n\n\nCREATE FUNCTION pg_catalog.trunc(value date, fmt text)\nRETURNS date\nAS '$libdir/orafce','ora"...) at extension.c:746
#10 execute_extension_script (extensionOid=extensionOid@entry=16385, control=control@entry=0x1a8b7d0,
    from_version=from_version@entry=0x0, version=version@entry=0x1a8b8b8 "3.3", requiredSchemas=requiredSchemas@entry=0x0,
    schemaName=schemaName@entry=0x1a8b7b0 "public", schemaOid=2200) at extension.c:906
#11 0x000000000058fc72 in CreateExtensionInternal (parents=parents@entry=0x0, stmt=<optimized out>, stmt=<optimized out>)
    at extension.c:1498
#12 0x00000000005901d8 in CreateExtension (stmt=stmt@entry=0x1a556d0) at extension.c:1556
#13 0x00000000006f8379 in ProcessUtilitySlow (parsetree=parsetree@entry=0x1a556d0,
    queryString=queryString@entry=0x1a54c78 "create extension orafce ;", context=context@entry=PROCESS_UTILITY_TOPLEVEL,
    params=params@entry=0x0, completionTag=completionTag@entry=0x7ffc5e408890 "", dest=0x1a55a58) at utility.c:1296
#14 0x00000000006f76bb in standard_ProcessUtility (parsetree=0x1a556d0, queryString=0x1a54c78 "create extension orafce ;",
    context=PROCESS_UTILITY_TOPLEVEL, params=0x0, dest=0x1a55a58, completionTag=0x7ffc5e408890 "") at utility.c:907
#15 0x00000000006f4ed4 in PortalRunUtility (portal=0x19f7aa8, utilityStmt=0x1a556d0, isTopLevel=<optimized out>, dest=0x1a55a58,
    completionTag=0x7ffc5e408890 "") at pquery.c:1175
#16 0x00000000006f5aa6 in PortalRunMulti (portal=portal@entry=0x19f7aa8, isTopLevel=isTopLevel@entry=1 '\001',
    dest=dest@entry=0x1a55a58, altdest=altdest@entry=0x1a55a58, completionTag=completionTag@entry=0x7ffc5e408890 "") at pquery.c:1306
#17 0x00000000006f66e6 in PortalRun (portal=portal@entry=0x19f7aa8, count=count@entry=9223372036854775807,
    isTopLevel=isTopLevel@entry=1 '\001', dest=dest@entry=0x1a55a58, altdest=altdest@entry=0x1a55a58,
    completionTag=completionTag@entry=0x7ffc5e408890 "") at pquery.c:813
#18 0x00000000006f401b in exec_simple_query (query_string=0x1a54c78 "create extension orafce ;") at postgres.c:1094
#19 PostgresMain (argc=<optimized out>, argv=argv@entry=0x19d9590, dbname=<optimized out>, username=<optimized out>)
    at postgres.c:4059
#20 0x000000000046dbb5 in BackendRun (port=0x19fbc60) at postmaster.c:4258
#21 BackendStartup (port=0x19fbc60) at postmaster.c:3932

This is enforced by sequence of statements REVOKE, GRANT

try to add following lines to hstore--1.3.sql

CREATE VIEW public.dual AS SELECT 'X'::varchar AS dummy;
REVOKE ALL ON public.dual FROM PUBLIC;
GRANT SELECT, REFERENCES ON public.dual TO PUBLIC;

then create extension hstore enforces this error.

When I remove the REVOKE statement - all is working.

Regards

Pavel

pgsql-hackers by date:

Previous
From: Kyotaro HORIGUCHI
Date:
Subject: Re: Support for N synchronous standby servers - take 2
Next
From: Peter Geoghegan
Date:
Subject: Re: SEGFAULT in CREATE EXTENSION related pg_init_privs