Re: [sqlite] [CRASH] Segmentation fault since 3.8.0

2013-09-04 Thread Alexandre Courbot
On Tue, Sep 3, 2013 at 9:20 PM, Richard Hipp  wrote:
> On Mon, Sep 2, 2013 at 11:07 PM, Alexandre Courbot  wrote:
>>
>> Hi everyone, (not subscribed to the ML, please CC)
>>
>> The following happens since 3.8.0 (tested on both 3.8.0 and 3.8.0.1):
>>
>> $ cat |sqlite3
>> create table t1(id INTEGER);
>> create table t2(id INTEGER, v INTEGER);
>> insert into t1 values(1);
>> select distinct t1.id from t1 left join t2 on t2.id = t1.id order by
>> t2.v is null;
>> Segmentation fault (core dumped)
>
>
> Thanks for the simple test case!  See
> http://www.sqlite.org/src/tktview/be84e357c03 for the ticket.  We'll get to
> work on this right away.

Seen on the ticket this has been fixed already, thanks for the quick reaction!

Alex.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] [CRASH] Segmentation fault since 3.8.0

2013-09-03 Thread Richard Hipp
On Tue, Sep 3, 2013 at 9:09 AM, Richard Hipp  wrote:

>
>
> We should have a proper fix before too long.
>
>
That fix can now be seen at http://www.sqlite.org/src/info/0303d6bc71
-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] [CRASH] Segmentation fault since 3.8.0

2013-09-03 Thread Richard Hipp
On Mon, Sep 2, 2013 at 11:07 PM, Alexandre Courbot  wrote:

> Hi everyone, (not subscribed to the ML, please CC)
>
> The following happens since 3.8.0 (tested on both 3.8.0 and 3.8.0.1):
>
> Could this be related to the new query planner?
>

No.  This seems to be due to the new optimization that strives to omit
unused tables from the query.  The optimizer was under the impression that
the second table (the one on the right of the LEFT JOIN) is not being used
and so it is omitted.  Somehow the optimizaer is missing the fact that the
second table is used in the ORDER BY clause.  The line of code at
http://www.sqlite.org/src/artifact/a37169b46fc?ln=5912 should detect that
the second table is used in the ORDER BY clause, but somehow it is not.
However this happens, the cursor object for this table is never opened, and
so when ORDER BY clause goes to try to extract values from the cursor, it
dereferences a NULL pointer and segfaults.

You can disable the optimization in the shell using:

.testctrl optimizations 0x400

Or from C code:

sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS, db, 0x400);

We should have a proper fix before too long.

-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] [CRASH] Segmentation fault since 3.8.0

2013-09-03 Thread Richard Hipp
On Mon, Sep 2, 2013 at 11:07 PM, Alexandre Courbot  wrote:

> Hi everyone, (not subscribed to the ML, please CC)
>
> The following happens since 3.8.0 (tested on both 3.8.0 and 3.8.0.1):
>
> $ cat |sqlite3
> create table t1(id INTEGER);
> create table t2(id INTEGER, v INTEGER);
> insert into t1 values(1);
> select distinct t1.id from t1 left join t2 on t2.id = t1.id order by
> t2.v is null;
> Segmentation fault (core dumped)
>

Thanks for the simple test case!  See
http://www.sqlite.org/src/tktview/be84e357c03 for the ticket.  We'll get to
work on this right away.


>
> The same statements with 3.7.17 do *not* crash.
>
> Removing the "distinct" keyword, selecting t2.id instead of t1.id, or
> ordeting on just t2.v result in a successful query. This seems
> triggered by the usage of "distinct", a left join, and ordering on a
> condition, but I haven't managed to narrow it further down. I am also
> not familiar enough with SQLite's internals to debug it further
> unfortunately. Could this be related to the new query planner?
>
> Alex.
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>



-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] [CRASH] Segmentation fault since 3.8.0

2013-09-03 Thread Alexandre Courbot
Hi everyone, (not subscribed to the ML, please CC)

The following happens since 3.8.0 (tested on both 3.8.0 and 3.8.0.1):

$ cat |sqlite3
create table t1(id INTEGER);
create table t2(id INTEGER, v INTEGER);
insert into t1 values(1);
select distinct t1.id from t1 left join t2 on t2.id = t1.id order by
t2.v is null;
Segmentation fault (core dumped)

The same statements with 3.7.17 do *not* crash.

Removing the "distinct" keyword, selecting t2.id instead of t1.id, or
ordeting on just t2.v result in a successful query. This seems
triggered by the usage of "distinct", a left join, and ordering on a
condition, but I haven't managed to narrow it further down. I am also
not familiar enough with SQLite's internals to debug it further
unfortunately. Could this be related to the new query planner?

Alex.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users