citusdata / postgresql-hll

PostgreSQL extension adding HyperLogLog data structures as a native data type
http://blog.aggregateknowledge.com/2013/02/04/open-source-release-postgresql-hll/
Apache License 2.0
1.12k stars 116 forks source link

segfault in hll_add_agg #91

Open will opened 4 years ago

will commented 4 years ago

versions

PostgreSQL 12.1 ( postgres/postgres@bf3cef24a319666 ) Citus 9.0.1 ( citusdata/citus@a853a824a5bc89 ) postgresql-hll v2.14, sha 2732580cd3c55fb55b794249a92295de87bf65c3

query

select public.hll_add_agg(cast(0 as hll_hashval), 29, 0);
server closed the connection unexpectedly
    This probably means the server terminated abnormally
    before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.

backtrace

* thread #1, name = 'postgres', stop reason = signal SIGSEGV: address access protected (fault address: 0x7f13f9cd6000)
    frame #0: 0x00007f13f73305f0 hll.so`multiset_packed_size at hll.c:983:13
   980      size_t nfilled = 0;
   981      size_t nregs = i_msp->ms_nregs;
   982      for (size_t ii = 0; ii < nregs; ++ii)
-> 983          if (mscp->msc_regs[ii] > 0)
   984              ++nfilled;
   985
   986      return nfilled;
(lldb) bt
* thread #1, name = 'postgres', stop reason = signal SIGSEGV: address access protected (fault address: 0x7f13f9cd6000)
  * frame #0: 0x00007f13f73305f0 hll.so`multiset_packed_size at hll.c:983:13
    frame #1: 0x00007f13f73305da hll.so`multiset_packed_size(i_msp=0x00007f13f730a048) at hll.c:1770
    frame #2: 0x00007f13f7333148 hll.so`hll_pack(fcinfo=0x00007fff151c6828) at hll.c:3508:19
    frame #3: 0x00000000006093bd postgres`finalize_aggregates at nodeAgg.c:964:17
    frame #4: 0x000000000060937c postgres`finalize_aggregates(aggstate=0x00000000029d7b70, peraggs=0x00000000029d8f98, pergroup=0x00000000029d9250) at nodeAgg.c:1172
    frame #5: 0x00000000006079ad postgres`ExecAgg [inlined] agg_retrieve_direct(aggstate=0x00000000029d7b70) at nodeAgg.c:1906:3
    frame #6: 0x000000000060742c postgres`ExecAgg(pstate=0x00000000029d7b70) at nodeAgg.c:1572
    frame #7: 0x00000000005f5f6a postgres`standard_ExecutorRun [inlined] ExecProcNode(node=<unavailable>) at executor.h:239:9
    frame #8: 0x00000000005f5f55 postgres`standard_ExecutorRun [inlined] ExecutePlan(estate=<unavailable>, planstate=0x00000000029d7b70, use_parallel_mode=<unavailable>, operation=<unavailable>, sendTuples=<unavailable>, numberTuples=0, direction=<unavailable>, dest=<unavailable>, execute_once=<unavailable>) at execMain.c:1646
    frame #9: 0x00000000005f5f14 postgres`standard_ExecutorRun(queryDesc=0x00000000029deb30, direction=NoMovementScanDirection, count=<unavailable>, execute_once=<unavailable>) at execMain.c:364
    frame #10: 0x00007f13f9aeafb8 citus.so`CitusExecutorRun(queryDesc=0x00000000029deb30, direction=ForwardScanDirection, count=0, execute_once=true) at multi_executor.c:151:3
    frame #11: 0x00007f13f99a464d pg_stat_statements.so`pgss_ExecutorRun + 157
    frame #12: 0x000000000073b48f postgres`PortalRunSelect(portal=0x0000000002952b00, forward=<unavailable>, count=0, dest=<unavailable>) at pquery.c:929:4
    frame #13: 0x000000000073b0c8 postgres`PortalRun(portal=0x0000000002952b00, count=9223372036854775807, isTopLevel=true, run_once=<unavailable>, dest=0x00000000029eca68, altdest=0x00000000029eca68, completionTag="") at pquery.c:770:18
    frame #14: 0x000000000073a183 postgres`exec_simple_query(query_string="select public.hll_add_agg(cast(0 as hll_hashval), 29, 0);") at postgres.c:1215:10
    frame #15: 0x0000000000738253 postgres`PostgresMain(argc=<unavailable>, argv=<unavailable>, dbname=<unavailable>, username=<unavailable>) at postgres.c:0
    frame #16: 0x00000000006c55f6 postgres`BackendRun(port=<unavailable>) at postmaster.c:4437:2
    frame #17: 0x00000000006c4d8e postgres`ServerLoop [inlined] BackendStartup(port=<unavailable>) at postmaster.c:4128:3
    frame #18: 0x00000000006c4d6a postgres`ServerLoop at postmaster.c:1704
    frame #19: 0x00000000006c2139 postgres`PostmasterMain(argc=<unavailable>, argv=0x00000000028bcd40) at postmaster.c:1377:11
    frame #20: 0x000000000063c826 postgres`main(argc=<unavailable>, argv=<unavailable>) at main.c:228:3
    frame #21: 0x00007f13fa05c1e3 libc.so.6`__libc_start_main + 243
    frame #22: 0x000000000047af7e postgres`_start + 46
serprex commented 4 years ago

Curious whether this is related to https://github.com/citusdata/postgresql-hll/pull/82/files#r328912635