harningt / luajson

JSON parser/encoder for Lua Parses JSON using LPEG for speed and flexibility. Depending on parser/encoder options, various values are preserved as best as possible.
http://www.eharning.us/wiki/luajson/
Other
251 stars 48 forks source link

lpeg error: too many pending calls/choices #14

Closed agladysh closed 12 years ago

agladysh commented 13 years ago

As described here:

http://thread.gmane.org/gmane.comp.lang.lua.general/78559/focus=78561

harningt commented 13 years ago

This is a pretty nasty glitch that I'm surprised I hadn't encountered before. Adding unit tests and adjusting parsing throughout where possible to handle this without too much degradation of performance.

harningt commented 13 years ago

Should be addressed in the latest branches: 1.0.x, 1.1.x, master, and next.

The stack depth is now limited by the Lua C stack depth limit - for every new array/object, a Cmt call is made to collect the values. Minimal tests show that ~190 is the maximum nesting for arrays/objects... much better than ~23

Will need to investigate performance impact and possible update for either next or master to redesign composite value type parsing.

Ticket left open since performance effect of the patch is unmeasured in both memory space and runtime.

harningt commented 13 years ago

Note: added unit tests will only test to the 190 depth if you set TEST_UNSAFE=true in the environment that the unit tests will run.

agladysh commented 13 years ago

Fix confirmed, thank you.

harningt commented 13 years ago

100% fixed in nonrecursive branch. tested a nested array of depth at least 10,000 w/ no problem

harningt commented 12 years ago

Resolved in 87fae51a2f1133392861e246cc5b423a175ba55c with a system that should only limit due to heap size and max size of Lua table.