SQLite Forum

Assertion failure when enable/disable optimizations

Assertion failure when enable/disable optimizations

(1) By Song Liu (songliu) on 2023-03-24 16:04:39 [source]

I found an assertion failure while SQLite (latest, 95c7af79cf) executes the following queries. The assertion failure may be caused by the optimizations. SQLite crashed by default with all optimizations enabled. If I disabled all optimizations, SQLite works well.

Here is the poc:

CREATE TABLE v1 ( c1 ); 
CREATE INDEX i1 ON v1 ( c1, c1, c1, c1, c1 || 2  ); 
CREATE INDEX i2 ON v1 ( 1 < 2 ); 

.testctrl optimizations 0xffffffff;
.print '-- disable optimization'

.testctrl optimizations 0x00000000;
.print '-- enable optimization'

Here are the outputs:

-- disable optimization
-- enable optimization
sqlite3: sqlite3.c:92063: sqlite3VdbeExec: Assertion `pIn1!=pOut' failed.
[1]    2667182 abort      ./sqlite3 < poc

My compilation flags:

    export CFLAGS="-g -O0 -DSQLITE_DEBUG 

(2) By Richard Hipp (drh) on 2023-03-24 17:03:23 in reply to 1 [link] [source]

The problem only arises when you are using STAT4. Disabling all optimizations disables STAT4, which is why it works with all optimizations disabled.

Now fixed on trunk and on branch-3.41.

(3) By Song Liu (songliu) on 2023-03-24 17:13:03 in reply to 2 [link] [source]

Thanks for your explanation and efforts!