Stack overflow with nested brackets

Aaron Ballman aaron at aaronballman.com
Wed Jul 24 12:34:29 PDT 2013


Patch LGTM; is there a way that we could add a test to ensure
diagnoseOverflow doesn't break again (since this is fixing a
regression)?

~Aaron

On Wed, Jul 24, 2013 at 2:28 PM, Rafael EspĂ­ndola
<rafael.espindola at gmail.com> wrote:
> 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




More information about the cfe-commits mailing list