PostgreSQL Bugs

Collected from the PG bugs email list.

Bug ID15428
PG Version11beta4
OSMacOS
Opened2018-10-12 09:00:12+00
Reported byMalthe Borch
StatusOpen

Body of first available message related to this bug follows.

The following bug has been logged on the website:

Bug reference:      15428
Logged by:          Malthe Borch
Email address:      (redacted)
PostgreSQL version: 11beta4
Operating system:   MacOS
Description:        

Using the extended query message flow, I prepare, bind and execute a query
as a named statement.

If I repeat this again with the query "execute <name>" – the backend crashes
with a segmentation fault due to an infinite recursion (see excerpt
below).

While it doesn't really make sense to prepare a statement that executes a
statement, there still seems to be a real issue here. It doesn't seem to
make a difference using the unnamed portal or a unique name per statement.

----

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS
(code=2, address=0x7ffeef3fffa8)
  * frame #0: 0x000000010073b49a postgres`dopr(target=<unavailable>,
format=<unavailable>, args=<unavailable>) at snprintf.c:377
    frame #1: 0x000000010073c84f postgres`pg_vsprintf(str="0\x04@??",
fmt="<unnamed portal %u>", args=0x00007ffeef4003c0) at snprintf.c:223
    frame #2: 0x000000010073ca0c postgres`pg_sprintf(str="0\x04@??",
fmt="<unnamed portal %u>") at snprintf.c:236
    frame #3: 0x000000010070d842 postgres`CreateNewPortal at
portalmem.c:244
    frame #4: 0x000000010025a3f2
postgres`ExecuteQuery(stmt=0x000000010200aa48,
intoClause=0x0000000000000000, queryString="execute test($1)",
params=0x0000000000000000, dest=0x000000010093da08, completionTag="") at
prepare.c:237
    frame #5: 0x0000000100512924
postgres`standard_ProcessUtility(pstmt=0x000000010200a9b0,
queryString="execute test($1)", context=PROCESS_UTILITY_QUERY,
params=0x0000000000000000, queryEnv=0x0000000000000000,
dest=0x000000010093da08, completionTag="") at utility.c:564
    frame #6: 0x00000001005123a5
postgres`ProcessUtility(pstmt=0x000000010200a9b0, queryString="execute
test($1)", context=PROCESS_UTILITY_QUERY, params=0x0000000000000000,
queryEnv=0x0000000000000000, dest=0x000000010093da08, completionTag="") at
utility.c:360
    frame #7: 0x0000000100511d87
postgres`PortalRunUtility(portal=0x000000010e912c88,
pstmt=0x000000010200a9b0, isTopLevel=<unavailable>,
setHoldSnapshot=<unavailable>, dest=<unavailable>, completionTag="") at
pquery.c:1178
    frame #8: 0x00000001005114e4
postgres`PortalRunMulti(portal=0x000000010e912c88, isTopLevel=false,
setHoldSnapshot=false, dest=0x000000010093da08, altdest=0x000000010093da08,
completionTag="") at pquery.c:0
    frame #9: 0x0000000100510d4e
postgres`PortalRun(portal=0x000000010e912c88, count=9223372036854775807,
isTopLevel=false, run_once=<unavailable>, dest=0x000000010093da08,
altdest=0x000000010093da08, completionTag="") at pquery.c:799
    frame #10: 0x000000010025a632
postgres`ExecuteQuery(stmt=0x000000010200aa48,
intoClause=0x0000000000000000, queryString="execute test($1)",
params=0x0000000000000000, dest=0x000000010093da08, completionTag="") at
prepare.c:304

Messages

DateAuthorSubject
2018-10-12 09:00:12+00=?utf-8?q?PG_Bug_reporting_form?=BUG #15428: "Inception" with recursive prepared statement causes infinite loop
2018-10-15 16:21:41+00Tom LaneRe: BUG #15428: "Inception" with recursive prepared statement causes infinite loop