Skip to content

qjson: Fix crash & save a lot of memory

Markus Armbruster qemu-devel 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest12 patches 13 repliesIn review
  2. v24 patches 9 repliesSuperseded
  3. v14 patches 10 repliesSuperseded

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/12qjson: Apply nesting limit more sanelyqobject/json-streamer.c+1 -20 replies
2/12qjson: Don't crash when input exceeds nesting limitqobject/json-streamer.c+3 -20 replies
3/12check-qjson: Add test for JSON nesting depth limittests/check-qjson.c+25 -00 replies
4/12qjson: Spell out some silent assumptionsinclude/qapi/qmp/json-lexer.h qobject/json-lexer.c+8 -21 reply
5/12qjson: Give each of the six structural chars its own token typeinclude/qapi/qmp/json-lexer.h qobject/json-lexer.c qobject/json-parser.c +1 more+42 -472 replies
6/12qjson: Inline token_is_keyword() and simplifyqobject/json-parser.c+7 -132 replies
7/12qjson: Inline token_is_escape() and simplifyqobject/json-parser.c+15 -172 replies
8/12qjson: replace QString in JSONLexer with GStringinclude/qapi/qmp/json-lexer.h include/qapi/qmp/json-streamer.h qobject/json-lexer.c +1 more+18 -221 reply
9/12qjson: Convert to parser to recursive descentqobject/json-parser.c+47 -1183 replies
10/12qjson: store tokens in a GQueueinclude/qapi/qmp/json-parser.h include/qapi/qmp/json-streamer.h monitor.c +5 more+45 -651 reply
11/12qjson: surprise, allocating 6 QObjects per token is expensiveinclude/qapi/qmp/json-streamer.h qobject/json-parser.c qobject/json-streamer.c+63 -781 reply
12/12qjson: Limit number of tokens in addition to total sizeqobject/json-streamer.c+2 -00 replies

Reviews trailers per patch

All 12 patches have a Reviewed-by or Acked-by.

PatchEric Blake
1/12R-b
2/12R-b
3/12R-b
4/12R-b
5/12R-b
6/12R-b
7/12R-b
8/12R-b
9/12R-b
10/12R-b
11/12R-b
12/12R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [Qemu-devel] [PATCH v3 for-2.5 00/12] qjson: Fix crash & save a lot of memory

This is a fusion of my "[PATCH v2 0/4] json-streamer: Fix up code to limit nesting and size" and Paolo's "[PATCH v2 for-2.5? 0/4] qjson:
save a lot of memory", with four straightforward cleanups thrown in to simplify the later patches.

PATCH 01-03 are about the nesting limit.

PATCH 04-07 are cleanups.

PATCH 09-11 are Paolo's, except I pretty much rewrote PATCH 10 to fully kill the backtracking.

PATCH 12 limits the number of tokens in addition to the total token size.

Why 2.5? In my opinion:

* PATCH 01-03 are simple fixes plus a new test.

* PATCH 04-11 reduce memory usage dramatically. Makes check-qjson's large_dict test (~100k tokens) run more than ten times faster.

If this is deemed too risky for 2.5, PATCH 12 needs to be replaced by v2 (different commit message, *much* lower limit).

* PATCH 12 is simple enough.

Markus Armbruster (9):
qjson: Apply nesting limit more sanely
qjson: Don't crash when input exceeds nesting limit
check-qjson: Add test for JSON nesting depth limit
qjson: Spell out some silent assumptions
qjson: Give each of the six structural chars its own token type
qjson: Inline token_is_keyword() and simplify
qjson: Inline token_is_escape() and simplify
qjson: Convert to parser to recursive descent
qjson: Limit number of tokens in addition to total size

Paolo Bonzini (3):
qjson: replace QString in JSONLexer with GString
qjson: store tokens in a GQueue
qjson: surprise, allocating 6 QObjects per token is expensive

 include/qapi/qmp/json-lexer.h    |  16 +-
 include/qapi/qmp/json-parser.h   |   4 +-
 include/qapi/qmp/json-streamer.h |  16 +-
 monitor.c                        |   2 +-
 qga/main.c                       |   2 +-
 qobject/json-lexer.c             |  48 +++---
 qobject/json-parser.c            | 330 ++++++++++++---------------------------
 qobject/json-streamer.c          |  89 ++++++-----
 qobject/qjson.c                  |   2 +-
 tests/check-qjson.c              |  25 +++
 tests/libqtest.c                 |   2 +-
 11 files changed, 223 insertions(+), 313 deletions(-)
Signature · 1 line
2.4.3