Stack overflow with nested brackets

Rafael EspĂ­ndola rafael.espindola at
Wed Jul 24 11:28:59 PDT 2013

BalancedDelimiterTracker::diagnoseOverflow calls P.SkipUntil which is
itself recursive. This can cause a stack overflow on systems that have
a limited stack. For example, on OS X with a debug build I get:

$ (ulimit -s 1000; ./bin/clang -cc1
~/llvm/clang/test/Parser/parser_overflow.c  -DHUGE > /dev/null 2>&1;
echo $?)

(ulimit -s 10000; ./bin/clang -cc1
~/llvm/clang/test/Parser/parser_overflow.c  -DHUGE > /dev/null 2>&1;
echo $?)

The attached patch fixes the problem by just special casing "skip to
the end of the file" to not try to balance tokens.

I found this while testing pipefail on windows, so it would get an
automatic test once we switch. check-all is clean, Is the patch ok?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: t.patch
Type: application/octet-stream
Size: 1057 bytes
Desc: not available
URL: <>

More information about the cfe-commits mailing list