Assertion failure in sqlite3VdbeExec function
(1) By Song Liu (songliu) on 2023-04-10 14:56:58 [source]
I found an assertion failure while SQLite (latest, 49ba030080dd00b4) executes the following queries.
CREATE TABLE v0 (c1 UNIQUE, c0);
INSERT INTO v0 (c0) VALUES (0);
CREATE VIEW v1 AS SELECT c1 COLLATE NOCASE FROM v0;
SELECT 0 FROM v0 LEFT JOIN v1 GROUP BY 1 HAVING (SELECT 0 FROM v0 LEFT JOIN v0 ON v1.c1);
Here are the outputs:
sqlite3: sqlite3.c:93391: sqlite3VdbeExec: Assertion `pC!=0' failed.
[1] 1895903 abort ./sqlite3 < poc
Here is the result of bisecting:
13 BAD 2022-07-25 16:06:14 b52393ac28debe98 CURRENT
12 GOOD 2022-07-25 11:04:13 836fa097060dadeb
The assertion failure may be caused by the optimizations. SQLite crashes by default with all optimizations enabled. If I disable the SQLITE_CoverIdxScan optimization, SQLite works well.
.testctrl optimizations 0x00000020;
My compilation flags:
export CFLAGS="-g -O0 -DSQLITE_DEBUG
-DSQLITE_ENABLE_TREETRACE
-DSQLITE_ENABLE_WHERETRACE
-DSQLITE_ENABLE_CURSOR_HINTS
-DSQLITE_COUNTOFVIEW_OPTIMIZATION
-DSQLITE_ENABLE_STAT4"
(2) By Richard Hipp (drh) on 2023-04-10 18:49:05 in reply to 1 [link] [source]
Fixed by 4c5a3c5fb351cc1c.
Note: This problem only exists in builds that use the SQLITE_ENABLE_CURSOR_HINTS compile-time option. The SQLITE_ENABLE_CURSOR_HINTS option is intended for use by COMDB2 only. If you are not using SQLite as part of COMDB2, then the SQLITE_ENABLE_CURSOR_HINTS compile-time option does nothing other than waste CPU cycles.
(3) By Song Liu (songliu) on 2023-04-11 14:32:28 in reply to 2 [link] [source]
Thanks for your detailed explanation and efforts!