Core was generated by `postgres: tomas test2 [local] SELECT '. Program terminated with signal SIGSEGV, Segmentation fault. #0 MemoryContextResetOnly (context=0x0) at mcxt.c:158 158 if (!context->isReset) (gdb) bt #0 MemoryContextResetOnly (context=0x0) at mcxt.c:158 #1 0x0000560f622f07b3 in tuplesort_reset (state=0x560f632e56a0) at tuplesort.c:1391 #2 0x0000560f620a2d17 in ExecIncrementalSort (pstate=0x560f632e1890) at nodeIncrementalSort.c:280 #3 0x0000560f6207d5da in ExecProcNode (node=0x560f632e1890) at ../../../src/include/executor/executor.h:239 #4 ExecutePlan (execute_once=, dest=0x560f632daf28, direction=, numberTuples=0, sendTuples=, operation=CMD_SELECT, use_parallel_mode=, planstate=0x560f632e1890, estate=0x560f632e1680) at execMain.c:1721 #5 standard_ExecutorRun (queryDesc=0x560f63233f60, direction=, count=0, execute_once=) at execMain.c:361 #6 0x0000560f621b8cfc in PortalRunSelect (portal=portal@entry=0x560f63277e40, forward=forward@entry=1 '\001', count=0, count@entry=9223372036854775807, dest=dest@entry=0x560f632daf28) at pquery.c:932 #7 0x0000560f621ba136 in PortalRun (portal=portal@entry=0x560f63277e40, count=count@entry=9223372036854775807, isTopLevel=isTopLevel@entry=1 '\001', run_once=run_once@entry=1 '\001', dest=dest@entry=0x560f632daf28, altdest=altdest@entry=0x560f632daf28, completionTag=0x7fffdd875ac0 "") at pquery.c:773 #8 0x0000560f621b60cb in exec_simple_query (query_string=0x560f63213820 "SELECT * FROM (SELECT * FROM t ORDER BY a) foo ORDER BY a, b;") at postgres.c:1120 #9 0x0000560f621b7df4 in PostgresMain (argc=, argv=argv@entry=0x560f63240678, dbname=, username=) at postgres.c:4144 #10 0x0000560f61ef56d1 in BackendRun (port=0x560f63236130) at postmaster.c:4412 #11 BackendStartup (port=0x560f63236130) at postmaster.c:4084 #12 ServerLoop () at postmaster.c:1757 #13 0x0000560f62148242 in PostmasterMain (argc=3, argv=0x560f6320e3e0) at postmaster.c:1365 #14 0x0000560f61ef66b7 in main (argc=3, argv=0x560f6320e3e0) at main.c:228