Seg fault using json_each() subquery

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Seg fault using json_each() subquery

Carlo Innocenti
I have a segmentation fault which happens when trying to run a subquery
based on json_each() if the argument is the value of an outer
json_each() row:

    CREATE TABLE mimmo (key TEXT PRIMARY KEY, value TEXT, valueJson
    TEXT, blockNo INTEGER, txnNo INTEGER, metadata TEXT);
    INSER INTO mimmo (key, valueJson) VALUES ('key2',
    '{"peppo":[["a","b"],["c","d"]]}');
    SELECT s.key FROM mimmo AS s, json_each(json_extract(s.valueJson,
    '$.peppo')) AS a WHERE (SELECT COUNT(*) FROM json_each(a.value)) > 0;

sqlite> select sqlite_version();
3.18.2

Am I doing anything obviously wrong? Or is this a known problem/limitation?
Thanks!
Minollo

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Seg fault using json_each() subquery

Richard Hipp-3
Unable to reproduce.  Are you sure you are sending the correct script?
 What operating system are you running on?  How did you compile
SQLite?

On 7/23/19, Carlo Innocenti <[hidden email]> wrote:
> I have a segmentation fault which happens when trying to run a subquery
> based on json_each() if the argument is the value of an outer
> json_each() row:
>
>     CREATE TABLE mimmo (key TEXT PRIMARY KEY, value TEXT, valueJson
>     TEXT, blockNo INTEGER, txnNo INTEGER, metadata TEXT);
>     INSER INTO mimmo (key, valueJson) VALUES ('key2',

Did you mean to say "INSERT" here, instead of "INSER"?

>     '{"peppo":[["a","b"],["c","d"]]}');
>     SELECT s.key FROM mimmo AS s, json_each(json_extract(s.valueJson,
>     '$.peppo')) AS a WHERE (SELECT COUNT(*) FROM json_each(a.value)) > 0;
>
> sqlite> select sqlite_version();
> 3.18.2
>
> Am I doing anything obviously wrong? Or is this a known problem/limitation?
> Thanks!
> Minollo
>
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>


--
D. Richard Hipp
[hidden email]
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Seg fault using json_each() subquery

Carlo Innocenti
I'm using sqlite with BDB as the persistence store; if you can't
reproduce it (same sqlite version), I suppose it means it's a BerkeleyDB
issue, and I'll follow up with them.
Thanks!

On 7/23/2019 12:01, Richard Hipp wrote:

> Unable to reproduce.  Are you sure you are sending the correct script?
>   What operating system are you running on?  How did you compile
> SQLite?
>
> On 7/23/19, Carlo Innocenti <[hidden email]> wrote:
>> I have a segmentation fault which happens when trying to run a subquery
>> based on json_each() if the argument is the value of an outer
>> json_each() row:
>>
>>      CREATE TABLE mimmo (key TEXT PRIMARY KEY, value TEXT, valueJson
>>      TEXT, blockNo INTEGER, txnNo INTEGER, metadata TEXT);
>>      INSER INTO mimmo (key, valueJson) VALUES ('key2',
> Did you mean to say "INSERT" here, instead of "INSER"?
>
>>      '{"peppo":[["a","b"],["c","d"]]}');
>>      SELECT s.key FROM mimmo AS s, json_each(json_extract(s.valueJson,
>>      '$.peppo')) AS a WHERE (SELECT COUNT(*) FROM json_each(a.value)) > 0;
>>
>> sqlite> select sqlite_version();
>> 3.18.2
>>
>> Am I doing anything obviously wrong? Or is this a known problem/limitation?
>> Thanks!
>> Minollo
>>
>> _______________________________________________
>> sqlite-users mailing list
>> [hidden email]
>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>>
>

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Seg fault using json_each() subquery

Charles Leifer
Partial traceback (bdb 18.1.32):

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff798e560 in jsonEachColumn () from ./lib/libdb_sql-18.1.so
(gdb) bt full
#0  0x00007ffff798e560 in jsonEachColumn () from ./lib/libdb_sql-18.1.so
No symbol table info available.
#1  0x00007ffff79b29b6 in sqlite3VdbeExec () from ./lib/libdb_sql-18.1.so
No symbol table info available.

Unfortunately this is next-to-useless, but may provide a clue?

On Tue, Jul 23, 2019 at 11:04 AM Carlo Innocenti <[hidden email]>
wrote:

> I'm using sqlite with BDB as the persistence store; if you can't
> reproduce it (same sqlite version), I suppose it means it's a BerkeleyDB
> issue, and I'll follow up with them.
> Thanks!
>
> On 7/23/2019 12:01, Richard Hipp wrote:
> > Unable to reproduce.  Are you sure you are sending the correct script?
> >   What operating system are you running on?  How did you compile
> > SQLite?
> >
> > On 7/23/19, Carlo Innocenti <[hidden email]> wrote:
> >> I have a segmentation fault which happens when trying to run a subquery
> >> based on json_each() if the argument is the value of an outer
> >> json_each() row:
> >>
> >>      CREATE TABLE mimmo (key TEXT PRIMARY KEY, value TEXT, valueJson
> >>      TEXT, blockNo INTEGER, txnNo INTEGER, metadata TEXT);
> >>      INSER INTO mimmo (key, valueJson) VALUES ('key2',
> > Did you mean to say "INSERT" here, instead of "INSER"?
> >
> >>      '{"peppo":[["a","b"],["c","d"]]}');
> >>      SELECT s.key FROM mimmo AS s, json_each(json_extract(s.valueJson,
> >>      '$.peppo')) AS a WHERE (SELECT COUNT(*) FROM json_each(a.value)) >
> 0;
> >>
> >> sqlite> select sqlite_version();
> >> 3.18.2
> >>
> >> Am I doing anything obviously wrong? Or is this a known
> problem/limitation?
> >> Thanks!
> >> Minollo
> >>
> >> _______________________________________________
> >> sqlite-users mailing list
> >> [hidden email]
> >> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
> >>
> >
>
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Seg fault using json_each() subquery

Keith Medcalf

Yes, that old version (from about 2 years ago) crashes (on Windows).  
No, the current one does not crash and produces two output lines.  

This is using your test SQL with the spelling errors fixed.

CREATE TABLE mimmo (key TEXT PRIMARY KEY, value TEXT, valueJson TEXT, blockNo INTEGER, txnNo INTEGER, metadata TEXT);
INSERT INTO mimmo (key, valueJson) VALUES ('key2', '{"peppo":[["a","b"],["c","d"]]}');
SELECT s.key FROM mimmo AS s, json_each(json_extract(s.valueJson, '$.peppo')) AS a WHERE (SELECT COUNT(*) FROM json_each(a.value)) > 0;

SQLite version 3.30.0 2019-07-23 21:48:21
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> CREATE TABLE mimmo (key TEXT PRIMARY KEY, value TEXT, valueJson TEXT, blockNo INTEGER, txnNo INTEGER, metadata TEXT);
sqlite> INSERT INTO mimmo (key, valueJson) VALUES ('key2', '{"peppo":[["a","b"],["c","d"]]}');
sqlite> SELECT s.key FROM mimmo AS s, json_each(json_extract(s.valueJson, '$.peppo')) AS a WHERE (SELECT COUNT(*) FROM json_each(a.value)) > 0;
key2
key2

bisect complete
  1 GOOD    2018-01-27 18:55:18 6ea8ba312c38365d
  4 GOOD    2018-01-26 22:41:59 7daa687340e47597
  7 BAD     2018-01-26 18:59:25 029ebcd30cb261d9 CURRENT
  6 BAD     2018-01-26 18:37:34 ace0644a1a2a42a3
  5 BAD     2018-01-25 20:50:46 30b9258294e3028e
  3 BAD     2018-01-24 18:28:39 090a64faaac579c6
  2 BAD     2018-01-23 20:22:15 b58b60b2c0729b73

--
The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume.


>-----Original Message-----
>From: sqlite-users [mailto:sqlite-users-
>[hidden email]] On Behalf Of Charles Leifer
>Sent: Tuesday, 23 July, 2019 20:08
>To: SQLite mailing list
>Subject: Re: [sqlite] Seg fault using json_each() subquery
>
>Partial traceback (bdb 18.1.32):
>
>Program received signal SIGSEGV, Segmentation fault.
>0x00007ffff798e560 in jsonEachColumn () from ./lib/libdb_sql-18.1.so
>(gdb) bt full
>#0  0x00007ffff798e560 in jsonEachColumn () from ./lib/libdb_sql-
>18.1.so
>No symbol table info available.
>#1  0x00007ffff79b29b6 in sqlite3VdbeExec () from ./lib/libdb_sql-
>18.1.so
>No symbol table info available.
>
>Unfortunately this is next-to-useless, but may provide a clue?
>
>On Tue, Jul 23, 2019 at 11:04 AM Carlo Innocenti
><[hidden email]>
>wrote:
>
>> I'm using sqlite with BDB as the persistence store; if you can't
>> reproduce it (same sqlite version), I suppose it means it's a
>BerkeleyDB
>> issue, and I'll follow up with them.
>> Thanks!
>>
>> On 7/23/2019 12:01, Richard Hipp wrote:
>> > Unable to reproduce.  Are you sure you are sending the correct
>script?
>> >   What operating system are you running on?  How did you compile
>> > SQLite?
>> >
>> > On 7/23/19, Carlo Innocenti <[hidden email]> wrote:
>> >> I have a segmentation fault which happens when trying to run a
>subquery
>> >> based on json_each() if the argument is the value of an outer
>> >> json_each() row:
>> >>
>> >>      CREATE TABLE mimmo (key TEXT PRIMARY KEY, value TEXT,
>valueJson
>> >>      TEXT, blockNo INTEGER, txnNo INTEGER, metadata TEXT);
>> >>      INSER INTO mimmo (key, valueJson) VALUES ('key2',
>> > Did you mean to say "INSERT" here, instead of "INSER"?
>> >
>> >>      '{"peppo":[["a","b"],["c","d"]]}');
>> >>      SELECT s.key FROM mimmo AS s,
>json_each(json_extract(s.valueJson,
>> >>      '$.peppo')) AS a WHERE (SELECT COUNT(*) FROM
>json_each(a.value)) >
>> 0;
>> >>
>> >> sqlite> select sqlite_version();
>> >> 3.18.2
>> >>
>> >> Am I doing anything obviously wrong? Or is this a known
>> problem/limitation?
>> >> Thanks!
>> >> Minollo
>> >>
>> >> _______________________________________________
>> >> sqlite-users mailing list
>> >> [hidden email]
>> >> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-
>users
>> >>
>> >
>>
>> _______________________________________________
>> sqlite-users mailing list
>> [hidden email]
>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-
>users
>>
>_______________________________________________
>sqlite-users mailing list
>[hidden email]
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Seg fault using json_each() subquery

Carlo Innocenti
Thanks Keith and Charles; the Berkeley DB folks are looking into it, and
I forwarded them this information.
Minollo

> Yes, that old version (from about 2 years ago) crashes (on Windows).
> No, the current one does not crash and produces two output lines.
>
> This is using your test SQL with the spelling errors fixed.
>
> CREATE TABLE mimmo (key TEXT PRIMARY KEY, value TEXT, valueJson TEXT, blockNo INTEGER, txnNo INTEGER, metadata TEXT);
> INSERT INTO mimmo (key, valueJson) VALUES ('key2', '{"peppo":[["a","b"],["c","d"]]}');
> SELECT s.key FROM mimmo AS s, json_each(json_extract(s.valueJson, '$.peppo')) AS a WHERE (SELECT COUNT(*) FROM json_each(a.value)) > 0;
>
> SQLite version 3.30.0 2019-07-23 21:48:21
> Enter ".help" for usage hints.
> Connected to a transient in-memory database.
> Use ".open FILENAME" to reopen on a persistent database.
> sqlite> CREATE TABLE mimmo (key TEXT PRIMARY KEY, value TEXT, valueJson TEXT, blockNo INTEGER, txnNo INTEGER, metadata TEXT);
> sqlite> INSERT INTO mimmo (key, valueJson) VALUES ('key2', '{"peppo":[["a","b"],["c","d"]]}');
> sqlite> SELECT s.key FROM mimmo AS s, json_each(json_extract(s.valueJson, '$.peppo')) AS a WHERE (SELECT COUNT(*) FROM json_each(a.value)) > 0;
> key2
> key2
>
> bisect complete
>    1 GOOD    2018-01-27 18:55:18 6ea8ba312c38365d
>    4 GOOD    2018-01-26 22:41:59 7daa687340e47597
>    7 BAD     2018-01-26 18:59:25 029ebcd30cb261d9 CURRENT
>    6 BAD     2018-01-26 18:37:34 ace0644a1a2a42a3
>    5 BAD     2018-01-25 20:50:46 30b9258294e3028e
>    3 BAD     2018-01-24 18:28:39 090a64faaac579c6
>    2 BAD     2018-01-23 20:22:15 b58b60b2c0729b73
>
> --
> The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume.
>
>
> >/-----Original Message----- />/From: sqlite-users [mailto:sqlite-users- />/bounces at mailinglists.sqlite.org
> <http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users>]
> On Behalf Of Charles Leifer />/Sent: Tuesday, 23 July, 2019 20:08 />/To: SQLite mailing list />/Subject: Re: [sqlite] Seg fault using json_each() subquery />//>/Partial traceback (bdb 18.1.32): />//>/Program received signal SIGSEGV, Segmentation fault. />/0x00007ffff798e560 in jsonEachColumn () from ./lib/libdb_sql-18.1.so />/(gdb) bt full />/#0 0x00007ffff798e560 in jsonEachColumn () from ./lib/libdb_sql- />/18.1.so />/No symbol table info available. />/#1 0x00007ffff79b29b6 in sqlite3VdbeExec () from ./lib/libdb_sql- />/18.1.so />/No symbol table info available. />//>/Unfortunately this is next-to-useless, but may provide a clue? />

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Seg fault using json_each() subquery

Carlo Innocenti
To close this thread, it looks like this issue is about a sqlite bug
which was fixed last year:

http://www2.sqlite.org/cgi/src/info/7daa687340e47597

Applying the changes described there to the BDB/SQLite code fixed the
issue I was experiencing.

Thanks for all the help,
Minollo


_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Seg fault using json_each() subquery

Charles Leifer
Carlo -- how do you get in touch with the BerkeleyDB folks? I've found and
fixed a couple issues with their SQLite build and have found no better
option that to post it on their "forum" and hope someone finds it.

Example I posted a few weeks ago with no response:

https://community.oracle.com/thread/4281490

I'd love to know how to get in touch with those folks to help contribute
fixes like this one.

On Wed, Jul 24, 2019 at 3:34 PM Carlo Innocenti <[hidden email]> wrote:

> To close this thread, it looks like this issue is about a sqlite bug
> which was fixed last year:
>
> http://www2.sqlite.org/cgi/src/info/7daa687340e47597
>
> Applying the changes described there to the BDB/SQLite code fixed the
> issue I was experiencing.
>
> Thanks for all the help,
> Minollo
>
>
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users