Hi,

I found a crash (segmentation fault) on jsonb.
This is the best I could do to reduce the query:

"""
select  
  75 as c1
from 
  public.pagg_tab_ml as ref_0,
  lateral (select  
        ref_0.a as c5 
      from generate_series(1, 300) as sample_0
      fetch first 78 rows only
      ) as subq_0
where case when (subq_0.c5 < 2) 
           then cast(null as jsonb) 
           else cast(null as jsonb) 
      end ? ref_0.c
"""

And because it needs pagg_tab_ml it should be run a regression database.
This affects at least 14 and 15.

Attached is the backtrace.

-- 
Jaime Casanova
Director de Servicios Profesionales
SystemGuards - Consultores de PostgreSQL
#0  0x0000556895e8b402 in getJsonbOffset (jc=0x5568971c2dd4, index=<optimized 
out>) at jsonb_util.c:146
        offset = 0
        i = 3158063
#1  0x0000556895e8ba44 in JsonbIteratorNext (it=it@entry=0x7fff141bac68, 
val=val@entry=0x7fff141bac40, skipNested=skipNested@entry=false) at 
jsonb_util.c:926
        __func__ = "JsonbIteratorNext"
#2  0x0000556895e89f47 in jsonb_hash (fcinfo=0x7fff141baca0) at jsonb_op.c:274
        jb = 0x5568971c2dd0
        it = 0x5568971c5958
        v = {type = jbvObject, val = {numeric = 0x556800303030, boolean = 48, 
string = {len = 3158064, val = 0x7fff141bac70 ""}, array = {nElems = 3158064, 
elems = 0x7fff141bac70, rawScalar = 136}, object = {
              nPairs = 3158064, pairs = 0x7fff141bac70}, binary = {len = 
3158064, data = 0x7fff141bac70}, datetime = {value = 93905168117808, typid = 
337357936, typmod = 32767, tz = -1782147448}}}
        r = <optimized out>
        hash = 0
        __func__ = "jsonb_hash"
#3  0x0000556895f56bba in FunctionCall1Coll 
(flinfo=flinfo@entry=0x5568971c2d38, collation=<optimized out>, arg1=<optimized 
out>) at fmgr.c:1138
        fcinfodata = {fcinfo = {flinfo = 0x5568971c2d38, context = 0x0, 
resultinfo = 0x0, fncollation = 100, isnull = false, nargs = 1, args = 
0x7fff141bacc0}, 
          fcinfo_data = "8-\034\227hU", '\000' <repeats 18 times>, 
"d\000\000\000\000\000\001\000x\277A\213\321\177\000\000\000'\033\227hU\000"}
        fcinfo = 0x7fff141baca0
        result = <optimized out>
        __func__ = "FunctionCall1Coll"
#4  0x0000556895c8830e in MemoizeHash_hash (tb=tb@entry=0x5568971c9490, 
key=key@entry=0x0) at nodeMemoize.c:175
        hkey = <optimized out>
        i = 0
        mstate = <optimized out>
        pslot = 0x5568971c2ca0
        hashkey = 0
        numkeys = 2
        hashfunctions = 0x5568971c2d38
        collations = 0x5568971a10e0
#5  0x0000556895c88b4f in memoize_insert (found=0x7fff141badbf, key=0x0, 
tb=0x5568971c9490) at ../../../src/include/lib/simplehash.h:758
        hash = <optimized out>
        hash = <optimized out>
#6  cache_lookup (mstate=mstate@entry=0x55689718c488, 
found=found@entry=0x7fff141badbf) at nodeMemoize.c:423
        key = <optimized out>
        entry = <optimized out>
        oldcontext = <optimized out>
#7  0x0000556895c89893 in ExecMemoize (pstate=0x55689718c488) at 
nodeMemoize.c:609
        entry = <optimized out>
        outerslot = <optimized out>
        found = false
        node = 0x55689718c488
        outerNode = <optimized out>
        slot = <optimized out>
        __func__ = "ExecMemoize"
#8  0x0000556895c62dc5 in ExecProcNodeFirst (node=0x55689718c488) at 
execProcnode.c:463
No locals.
#9  0x0000556895c918f1 in ExecProcNode (node=0x55689718c488) at 
../../../src/include/executor/executor.h:257
No locals.
#10 ExecNestLoop (pstate=0x55689718aba8) at nodeNestloop.c:160
        node = 0x55689718aba8
        nl = 0x5568971a1158
        innerPlan = 0x55689718c488
        outerPlan = 0x55689718adb0
        outerTupleSlot = <optimized out>
        innerTupleSlot = <optimized out>
        joinqual = 0x0
        otherqual = 0x0
        econtext = 0x55689718acc0
        lc = <optimized out>
#11 0x0000556895c62dc5 in ExecProcNodeFirst (node=0x55689718aba8) at 
execProcnode.c:463
No locals.
#12 0x0000556895c5af50 in ExecProcNode (node=0x55689718aba8) at 
../../../src/include/executor/executor.h:257
No locals.
#13 ExecutePlan (estate=estate@entry=0x55689718a8a0, planstate=0x55689718aba8, 
use_parallel_mode=<optimized out>, operation=operation@entry=CMD_SELECT, 
sendTuples=sendTuples@entry=true, 
    numberTuples=numberTuples@entry=0, direction=ForwardScanDirection, 
dest=0x5568971a2938, execute_once=true) at execMain.c:1551
        slot = <optimized out>
        current_tuple_count = 0
#14 0x0000556895c5bbf1 in standard_ExecutorRun (queryDesc=0x5568971772f0, 
direction=ForwardScanDirection, count=0, execute_once=<optimized out>) at 
execMain.c:361
        estate = 0x55689718a8a0
        operation = CMD_SELECT
        dest = 0x5568971a2938
        sendTuples = true
        oldcontext = 0x5568971771d0
        __func__ = "standard_ExecutorRun"
#15 0x0000556895c5bcba in ExecutorRun 
(queryDesc=queryDesc@entry=0x5568971772f0, 
direction=direction@entry=ForwardScanDirection, count=count@entry=0, 
execute_once=<optimized out>) at execMain.c:305
No locals.
#16 0x0000556895e17fe9 in PortalRunSelect (portal=portal@entry=0x5568971138c0, 
forward=forward@entry=true, count=0, count@entry=9223372036854775807, 
dest=dest@entry=0x5568971a2938) at pquery.c:919
        queryDesc = 0x5568971772f0
        direction = <optimized out>
        nprocessed = <optimized out>
        __func__ = "PortalRunSelect"
#17 0x0000556895e19a27 in PortalRun (portal=portal@entry=0x5568971138c0, 
count=count@entry=9223372036854775807, isTopLevel=isTopLevel@entry=true, 
run_once=run_once@entry=true, dest=dest@entry=0x5568971a2938, 
    altdest=altdest@entry=0x5568971a2938, qc=0x7fff141bb1a0) at pquery.c:763
        _save_exception_stack = 0x7fff141bb240
        _save_context_stack = 0x0
        _local_sigjmp_buf = {{__jmpbuf = {0, 2866417797863591563, 
93907699719656, 93907699448000, 93907699448000, 93907700033848, 
2866417798041849483, 8280022089377533579}, __mask_was_saved = 0, 
            __saved_mask = {__val = {93907699459584, 140733530747088, 
93907699456208, 93907682679101, 112, 93907699719656, 93907699009424, 0, 177, 
140733530747152, 93907681006066, 93907699448000, 2, 
                93907699719656, 93907699448000, 140733530747184}}}}
        _do_rethrow = <optimized out>
        result = <optimized out>
        nprocessed = <optimized out>
        saveTopTransactionResourceOwner = 0x5568970daba0
        saveTopTransactionContext = 0x55689712b3e0
        saveActivePortal = 0x0
        saveResourceOwner = 0x5568970daba0
        savePortalContext = 0x0
        saveMemoryContext = 0x55689712b3e0
        __func__ = "PortalRun"
#18 0x0000556895e159c3 in exec_simple_query (
    query_string=query_string@entry=0x5568970a88b0 "select  \n  75 as c1\nfrom 
\n  public.pagg_tab_ml as ref_0,\n  lateral (select  \n        ref_0.a as c5 \n 
     from generate_series(1, 300) as sample_0\n      fetch first 78 rows only\n 
     ) as subq_0\nwher"...) at postgres.c:1214
        snapshot_set = <optimized out>
        per_parsetree_context = 0x0
        plantree_list = 0x5568971a28e0
        parsetree = 0x556897155de8
        commandTag = <optimized out>
        qc = {commandTag = CMDTAG_UNKNOWN, nprocessed = 0}
        querytree_list = <optimized out>
        portal = 0x5568971138c0
        receiver = 0x5568971a2938
        format = 0
        parsetree_item__state = <optimized out>
        dest = DestRemote
        oldcontext = 0x55689712b3e0
        parsetree_list = 0x556897155e20
        parsetree_item = 0x556897155e38
        save_log_statement_stats = false
        was_logged = false
        use_implicit_block = false
        msec_str = 
"\340\344\f\227hU\000\000\b\000\000\000\000\000\000\000\340\261\033\024\377\177\000\000\a6\366\225hU\000"
        __func__ = "exec_simple_query"
#19 0x0000556895e17920 in PostgresMain (dbname=<optimized out>, 
username=<optimized out>) at postgres.c:4497
        query_string = 0x5568970a88b0 "select  \n  75 as c1\nfrom \n  
public.pagg_tab_ml as ref_0,\n  lateral (select  \n        ref_0.a as c5 \n     
 from generate_series(1, 300) as sample_0\n      fetch first 78 rows only\n     
 ) as subq_0\nwher"...
        firstchar = <optimized out>
        input_message = {
          data = 0x5568970a88b0 "select  \n  75 as c1\nfrom \n  
public.pagg_tab_ml as ref_0,\n  lateral (select  \n        ref_0.a as c5 \n     
 from generate_series(1, 300) as sample_0\n      fetch first 78 rows only\n     
 ) as subq_0\nwher"..., len = 292, maxlen = 1024, cursor = 292}
        local_sigjmp_buf = {{__jmpbuf = {140733530747424, 2866417797924408971, 
3734544627, 93907699164384, 8, 93907699164384, 2866417797901340299, 
8280022092944789131}, __mask_was_saved = 1, __saved_mask = {
              __val = {4194304, 18446744073709551536, 15616, 93907699164384, 
140538101695459, 0, 93907698982752, 140733530747664, 15616, 15680, 
93907680973955, 0, 93907698982752, 15616, 93907699164384, 8}}}}
        send_ready_for_query = false
        idle_in_transaction_timeout_enabled = false
        idle_session_timeout_enabled = false
        __func__ = "PostgresMain"
#20 0x0000556895d74fd1 in BackendRun (port=port@entry=0x5568970ce4e0) at 
postmaster.c:4560
No locals.
#21 0x0000556895d7806c in BackendStartup (port=port@entry=0x5568970ce4e0) at 
postmaster.c:4288
        bn = 0x5568970ccd10
        pid = 0
        __func__ = "BackendStartup"
#22 0x0000556895d78287 in ServerLoop () at postmaster.c:1801
        port = 0x5568970ce4e0
        i = 2
        rmask = {fds_bits = {128, 0 <repeats 15 times>}}
        selres = <optimized out>
        now = <optimized out>
        readmask = {fds_bits = {224, 0 <repeats 15 times>}}
        nSockets = 8
        last_lockfile_recheck_time = 1632938181
        last_touch_time = 1632935069
        __func__ = "ServerLoop"
#23 0x0000556895d79827 in PostmasterMain (argc=3, argv=<optimized out>) at 
postmaster.c:1473
        opt = <optimized out>
        status = <optimized out>
        userDoption = <optimized out>
        listen_addr_saved = true
        i = <optimized out>
        output_config_variable = <optimized out>
        __func__ = "PostmasterMain"
#24 0x0000556895cba084 in main (argc=3, argv=0x5568970a1ec0) at main.c:198
No locals.

Reply via email to