Branch: refs/heads/main
Revision: d90ddcd
Author: dlongnecke-cray
Link: Define YYSTYPE_IS_TRIVIAL in both the dyno and old parser by dlongnecke-cray · Pull Request #20013 · chapel-lang/chapel · GitHub
Log Message:
Merge pull request #20013 from dlongnecke-cray/dyno-parser-nested-if
Define YYSTYPE_IS_TRIVIAL in both the dyno and old parser (#20013)
Resolves #19921.
Define YYSTYPE_IS_TRIVIAL in both parsers to tell Bison that the
data type it uses to store the results of productions can be
bitcopied. This fixes a bug in which parsing a nested if/else
with a relatively shallow depth (50 branches) led to an out of
memory error.
While here, also improve the output of memory exhausted error
messages to say: memory exhausted while parsing.
For some context: when compiling with __cplusplus, the generated
Bison parser will only resize the stack it uses for parsing
beyond its default size of 200 if it sees YYSTYPE_IS_TRIVIAL
is true. This is normally only defined when we create the YYSTYPE
union using the Bison %union directive. Since we didn't do that
in either parser (I don't know why), the parser never regrew its
stack.
While here, add a test superbigif.chpl which tests an if with
a branch depth of 500. There is a script that can be used to
generate a larger depth size if needed.
The max depth I was able to hit on my machine before hitting the
memory exhausted error was 2497. However I still got crashes
further in compilation. ASAN seemed to hint it was due to a stack
overflow (I saw that I was at least 6000 frames deep in LLDB).
Reviewed by @mppf. Thanks!
TESTING
-
ALLonlinux64,standard
Signed-off-by: David Longnecker dlongnecke-cray@users.noreply.github.com
Modified Files:
A test/parsing/gensuperbigif.py
A test/parsing/superbigif.chpl
A test/parsing/superbigif.good
R test/parsing/bigifthenelse.future
M compiler/dyno/lib/parsing/bison-chpl-lib.cpp
M compiler/dyno/lib/parsing/bison-chpl-lib.h
M compiler/dyno/lib/parsing/chpl.ypp
M compiler/dyno/lib/parsing/parser-yyerror.h
M compiler/include/bison-chapel.h
M compiler/include/flex-chapel.h
M compiler/parser/bison-chapel.cpp
M compiler/parser/chapel.ypp
M compiler/parser/flex-chapel.cpp
Compare: https://github.com/chapel-lang/chapel/compare/8b365fe8ba83...d90ddcda3d74