Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault on a query from table expression #3418

Closed
monetdb-team opened this issue Nov 30, 2020 · 0 comments
Closed

Segmentation fault on a query from table expression #3418

monetdb-team opened this issue Nov 30, 2020 · 0 comments
Labels
bug Something isn't working major MAL/M5

Comments

@monetdb-team
Copy link

Date: 2014-01-14 15:31:17 +0100
From: Alex Shestakov <<shura.shestakov>>
To: MonetDB5 devs <>
Version: 11.15.19 (Feb2013-SP6)
CC: @mlkersten, @drstmane

Last updated: 2014-02-20 15:02:45 +0100

Comment 19446

Date: 2014-01-14 15:31:17 +0100
From: Alex Shestakov <<shura.shestakov>>

User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36
Build Identifier:

I have a table DailyData defined as follows.

create table DailyData (
sym varchar(32),
businessdate date,
closePrice float,
adjustedClosePrice float,
openingPrice float,
accVol float,
unique(businessdate, sym)
);

I make the following query.

with dd as (select * from DailyData where businessdate > '2013-06-01'),
r as (select t.businessdate, t.sym, 1 - t.adjustedcloseprice / y.adjustedcloseprice as ret from dd t
left outer join dd y on t.businessdate = y.businessdate + (interval '1' day) and t.sym = y.sym),
v as (select sym, stddev_samp(ret) as volatility from r group by sym)
select * from v where v.sym like '%.L' limit 100;

It results in a segmentation fault:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7f5f17023700 (LWP 25178)]
0x0000003ee9327a9a in __strcmp_sse42 () from /lib64/libc.so.6
(gdb) where
0 0x0000003ee9327a9a in __strcmp_sse42 () from /lib64/libc.so.6
1 0x00007f6f2d4ef6f8 in rel_use_index (changes=, sql=0x7f5f08005470, rel=0x7f5f0850aa70) at rel_optimizer.c:4829
2 0x00007f6f2d4ea225 in rewrite (sql=0x7f5f08005470, rel=0x7f5f0850aa70, rewriter=0x7f6f2d4ef610 <rel_use_index>, has_changes=0x7f5f17022cac) at rel_optimizer.c:6106
3 0x00007f6f2d4ea2bc in rewrite (sql=0x7f5f08005470, rel=0x7f5f0850cb40, rewriter=0x7f6f2d4ef610 <rel_use_index>, has_changes=0x7f5f17022cac) at rel_optimizer.c:6093
4 0x00007f6f2d4ea2bc in rewrite (sql=0x7f5f08005470, rel=0x7f5f0850ec30, rewriter=0x7f6f2d4ef610 <rel_use_index>, has_changes=0x7f5f17022cac) at rel_optimizer.c:6093
5 0x00007f6f2d4ea2bc in rewrite (sql=0x7f5f08005470, rel=0x7f5f0850ef50, rewriter=0x7f6f2d4ef610 <rel_use_index>, has_changes=0x7f5f17022cac) at rel_optimizer.c:6093
6 0x00007f6f2d4ea2bc in rewrite (sql=0x7f5f08005470, rel=0x7f5f08512a90, rewriter=0x7f6f2d4ef610 <rel_use_index>, has_changes=0x7f5f17022cac) at rel_optimizer.c:6093
7 0x00007f6f2d4ea2bc in rewrite (sql=0x7f5f08005470, rel=0x7f5f0850feb0, rewriter=0x7f6f2d4ef610 <rel_use_index>, has_changes=0x7f5f17022cac) at rel_optimizer.c:6093
8 0x00007f6f2d4ea2bc in rewrite (sql=0x7f5f08005470, rel=0x7f5f085101c0, rewriter=0x7f6f2d4ef610 <rel_use_index>, has_changes=0x7f5f17022cac) at rel_optimizer.c:6093
9 0x00007f6f2d4ecf58 in _rel_optimizer (sql=0x7f5f08005470, rel=, level=0) at rel_optimizer.c:6278
10 0x00007f6f2d484369 in sql_symbol2relation (c=0x7f5f08005470, sym=) at sql.mx:1755
11 0x00007f6f2d454b2f in SQLparser (c=0x7f6f2df49308) at sql_scenario.c:1708
12 0x00007f6f352ecdd3 in runPhase (c=0x7f6f2df49308) at mal_scenario.c:522
13 runScenarioBody (c=0x7f6f2df49308) at mal_scenario.c:558
14 0x00007f6f352ecf1f in runScenario (c=0x7f6f2df49308) at mal_scenario.c:586
15 0x00007f6f352ed778 in MSserveClient (dummy=0x7f6f2df49308) at mal_session.c:446
16 0x0000003ee9a07851 in start_thread () from /lib64/libpthread.so.0
17 0x0000003ee92e890d in clone () from /lib64/libc.so.6

Apparently at rel_optimizer.c:4829 strcmp(exp_relname(nre) returns NULL which is not checked.

If I rewrite the query in the following way it works if not very fast.

with r as (select t.businessdate, t.sym, 1 - t.adjustedcloseprice / y.adjustedcloseprice as ret from DailyData t
left outer join DailyData y on t.businessdate = y.businessdate + (interval '1' day) and t.sym = y.sym
where t.businessdate > '2013-06-01'),
v as (select sym, stddev_samp(ret) as volatility from r group by sym)
select * from v where v.sym like '%.L' limit 100;

Reproducible: Always

Comment 19447

Date: 2014-01-14 15:58:19 +0100
From: @mlkersten

Not confirmed on the main trunk.

Comment 19448

Date: 2014-01-14 16:54:00 +0100
From: @drstmane

Confirmed (i.e., segfault does occur) with Feb2013-SP6.

Comment 19449

Date: 2014-01-14 16:55:30 +0100
From: @drstmane

Query appears to work fine (on empty table) with the Jan2014 release candidate branch.

Comment 19450

Date: 2014-01-15 14:50:06 +0100
From: Alex Shestakov <<shura.shestakov>>

I can confirm that the bug is fixed in Jan2014 release candidate.

Comment 19465

Date: 2014-01-20 15:16:47 +0100
From: MonetDB Mercurial Repository <>

Changeset 1bcf7aae3e03 made by Sjoerd Mullender sjoerd@acm.org in the MonetDB repo, refers to this bug.

For complete details, see http//devmonetdborg/hg/MonetDB?cmd=changeset;node=1bcf7aae3e03

Changeset description:

Added test for bug #3418.

Comment 19467

Date: 2014-01-20 15:20:21 +0100
From: @sjoerdmullender

Bug seems to be fixed in the upcoming release.

Comment 19606

Date: 2014-02-20 15:02:45 +0100
From: @sjoerdmullender

Jan2014 has been released.

@monetdb-team monetdb-team added bug Something isn't working major MAL/M5 labels Nov 30, 2020
@sjoerdmullender sjoerdmullender added this to the Ancient Release milestone Feb 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working major MAL/M5
Projects
None yet
Development

No branches or pull requests

2 participants