Stack overflow with nested brackets

Rafael EspĂ­ndola rafael.espindola at gmail.com
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 $?)
139

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

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?

Cheers,
Rafael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t.patch
Type: application/octet-stream
Size: 1057 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130724/2fd6eaeb/attachment.obj>


More information about the cfe-commits mailing list