SQLite

View Ticket
Login
2017-04-11
18:55 Fixed ticket [981329ad]: Stack overflow while parsing deeply nested JSON plus 5 other changes (artifact: 86a95386 user: drh)
18:55
Limit the depth of recursion for valid JSON in the JSON1 extension in order to avoid using excess stack space in the recursive descent parser. Fix for ticket [981329adeef51011052667a9]. (check-in: 1f68c184 user: drh tags: trunk)
18:09 New ticket [981329ad] Stack overflow while parsing deeply nested JSON. (artifact: 85802dae user: drh)

Ticket Hash: 981329adeef51011052667a951108c01113d131c
Title: Stack overflow while parsing deeply nested JSON
Status: Fixed Type: Code_Defect
Severity: Severe Priority: Immediate
Subsystem: Unknown Resolution: Fixed
Last Modified: 2017-04-11 18:55:12
Version Found In: 3.18.0
User Comments:
drh added on 2017-04-11 18:09:39:

The following query causes a stack overflow in the JSON parser:

WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<400000)
SELECT json_valid(group_concat('[', '')) FROM c;

This problem was reported on the SQLite mailing list by Ralf Junker and is based on the n_structure_100000_opening_arrays.json test case from the JSONTestSuite.