Skip to content

Commit 02ac36b

Browse files
authored
Merge commit from fork
Lower `CJSON_NESTING_LIMIT` from upstream default 1000 to 64 via `SWITCH_AM_CFLAGS` / `SWITCH_AM_CXXFLAGS`. The mutually recursive `parse_value`/`parse_array`/`parse_object` chain in cJSON consumes ~2 stack frames per nesting level, which can overflow worker threads running on `SWITCH_THREAD_STACKSIZE` (240 KB).
1 parent 74d3208 commit 02ac36b

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

configure.ac

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,11 @@ SWITCH_AM_CXXFLAGS="-I${switch_srcdir}/src/include -I${switch_builddir}/src/incl
308308
SWITCH_AM_CPPFLAGS="-I${switch_srcdir}/src/include -I${switch_builddir}/src/include -I${switch_srcdir}/libs/libteletone/src"
309309
SWITCH_AM_LDFLAGS="-lm"
310310

311+
# Cap cJSON parser recursion depth. Default upstream limit (1000) can overflow
312+
# small thread stacks; both vendored cJSON copies (src/ and libs/esl/) honor this.
313+
APR_ADDTO(SWITCH_AM_CFLAGS, [-DCJSON_NESTING_LIMIT=64])
314+
APR_ADDTO(SWITCH_AM_CXXFLAGS, [-DCJSON_NESTING_LIMIT=64])
315+
311316
#set SOLINK variable based on compiler and host
312317
if test "x${ax_cv_c_compiler_vendor}" = "xsun" ; then
313318
SOLINK="-Bdynamic -dy -G"

0 commit comments

Comments
 (0)