Hello,
I think I've found a bug in SQLite3, I get an assertion fault (or
segmentation fault in release build) when running a somewhat complicated
nested select statement:
% sqlite3 -init sqlite3-bug.sql bla.sqlite3
-- Loading resources from sqlite3-bug.sql
sqlite3: sqlite3.c:65666: sqlite3VdbeExec: Assertion `u.an.pC!=0' failed.
zsh: abort sqlite3 -init sqlite3-bug.sql bla.sqlite3
It is 100% reproduceable. I stripped down my statement and schema I used
to create a small example. See bottom of this mail for the content of
sqlite3-bug.sql.
I'm running 64-bit linux.
Regards,
Alex
GDB backtrace:
Program received signal SIGABRT, Aborted.
0x00007ffff7535c15 in raise () from /lib64/libc.so.6
(gdb) bt
#0 0x00007ffff7535c15 in raise () from /lib64/libc.so.6
#1 0x00007ffff753708b in abort () from /lib64/libc.so.6
#2 0x00007ffff752ec7e in __assert_fail_base () from /lib64/libc.so.6
#3 0x00007ffff752ed22 in __assert_fail () from /lib64/libc.so.6
#4 0x00007ffff7b997e1 in sqlite3VdbeExec () from /usr/lib64/libsqlite3.so.0
#5 0x00007ffff7b70927 in sqlite3_step () from /usr/lib64/libsqlite3.so.0
#6 0x00000000004052c4 in shell_exec.constprop.7 ()
#7 0x0000000000405d49 in process_input ()
#8 0x0000000000402783 in main ()
Compiled using:
./configure --prefix=/usr --build=x86_64-pc-linux-gnu
--host=x86_64-pc-linux-gnu --mandir=/usr/share/man
--infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc
--localstatedir=/var/lib --libdir=/usr/lib64
--disable-dependency-tracking --disable-static
--enable-dynamic-extensions --enable-readline --enable-threadsafe
% sqlite3 -version
3.7.14.1 2012-10-04 19:37:12 091570e46d04e84b67228e0bdbcd6e1fb60c6bdb
% gcc --version
gcc (Gentoo 4.6.3 p1.6, pie-0.5.2) 4.6.3
% uname -a
Linux inspiron 3.4.11-tuxonice #1 SMP PREEMPT Sat Sep 29 18:58:19 CEST
2012 x86_64 Intel(R) Core(TM)2 Duo CPU P7450 @ 2.13GHz GenuineIntel
GNU/Linux
% cat ~/.sqliterc
-- SQLite3 command line configuration
.timer ON
.headers ON
.mode column
.width 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
-- vim: ft=sql
% cat sqlite3-bug.sql
-- schema
CREATE TABLE AAA (
aaa_id INTEGER PRIMARY KEY AUTOINCREMENT
);
CREATE TABLE RRR (
rrr_id INTEGER PRIMARY KEY AUTOINCREMENT,
rrr_date INTEGER NOT NULL,
rrr_aaa INTEGER
);
CREATE TABLE TTT (
ttt_id INTEGER PRIMARY KEY AUTOINCREMENT,
target_aaa INTEGER NOT NULL,
source_aaa INTEGER NOT NULL
);
-- insert
insert into AAA (aaa_id)
values (2);
insert into TTT (ttt_id, target_aaa, source_aaa)
values (4469, 2, 2);
insert into TTT (ttt_id, target_aaa, source_aaa)
values (4476, 2, 1);
insert into RRR (rrr_id, rrr_date, rrr_aaa)
values (0, 0, NULL);
insert into RRR (rrr_id, rrr_date, rrr_aaa)
values (2, 4312, 2);
-- segfault
SELECT i.aaa_id,
(SELECT sum(CASE WHEN (t.source_aaa == i.aaa_id) THEN 1 ELSE 0 END)
FROM TTT t
) AS segfault
FROM (SELECT curr.rrr_aaa as aaa_id
FROM RRR curr
-- you also can comment out the next line -- it causes
segfault to happen after one row is outputted
INNER JOIN AAA a ON (curr.rrr_aaa = aaa_id)
LEFT JOIN RRR r ON (r.rrr_id <> 0 AND r.rrr_date <
curr.rrr_date)
GROUP BY curr.rrr_id
HAVING r.rrr_date IS NULL
) i;
.quit
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users