knizhnik / imcs

In-Memory Columnar Store extension for PostgreSQL
Apache License 2.0
203 stars 33 forks source link

Segmentation fault in imcs_next_tile #58

Closed pavitrakumar78 closed 4 years ago

pavitrakumar78 commented 4 years ago

Hi,

I tried executing the following query but the db connection was closed due to a seg fault.

Query:

select Symbol from (select Symbol, (select cs_count(
        cs_filter_pos(((cs_window_avg((Close), 15)<<(14))<<(25))>(cs_window_avg((Close), 40)<<(39)))
        ) from  Quotes_get(Symbol, '2020-06-13', '2020-09-04')) cnt from SecurityQuotes) s2 where cnt>0;

Segfault from gdb:

Thread 1 "postgres" received signal SIGSEGV, Segmentation fault.
0x00007fa982d26aae in imcs_next_tile () from /usr/lib/postgresql/12/lib/imcs.so

The following query without with just the SMA comparison for a single symbol works:

select ((cs_window_avg((Close), 15)<<(14))<<(25))>(cs_window_avg((Close), 40)<<(39)) 
from Quotes_get('SPY', '2020-06-13', '2020-09-04');

Not sure why this happens. I can verify that I have data from 2020-6 to 2020-09 and the shifts are also correct (shifts are added so that the array values are aligned properly). My memory consumption is also <70% when executing this so I don't think this could be due to low memory either.

knizhnik commented 4 years ago

Can you try please to reproduce the problem with this patch?

pavitrakumar78 commented 4 years ago

Can you try please to reproduce the problem with this patch?

It works! I do not get any seg faults anymore! I also tried with few similar queries and they all worked fine!

Thank you for the fix! I'll close the issue now.