Module: Mesa Branch: 7.10 Commit: 6d35d0bda67d528dfca4897d57ec61f6839c9a6b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6d35d0bda67d528dfca4897d57ec61f6839c9a6b
Author: Carl Worth <[email protected]> Date: Fri Apr 15 12:03:25 2011 -0700 glcpp: Fix attempts to expand recursive macros infinitely (bug #32835). The 095-recursive-define test case was triggering infinite recursion with the following test case: #define A(a, b) B(a, b) #define C A(0, C) C Here's what was happening: 1. "C" was pushed onto the active list to expand the C node 2. While expanding the "0" argument, the active list would be emptied by the code at the end of _glcpp_parser_expand_token_list 3. When expanding the "C" argument, the active list was now empty, so lather, rinse, repeat. We fix this by adjusting the final popping at the end of _glcpp_parser_expand_token_list to never pop more nodes then this particular invocation had pushed itself. This is as simple as saving the original state of the active list, and then interrupting the popping when we reach this same state. With this fix, all of the glcpp-test tests now pass. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=32835 Signed-off-by: Carl Worth <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-and-tested-by: Kenneth Graunke <[email protected]> (cherry picked from commit 9dacbe222641443af000a82161922a5ade206340) --- src/glsl/glcpp/glcpp-parse.y | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index 5eed9c0..bf94592 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -1561,6 +1561,7 @@ _glcpp_parser_expand_token_list (glcpp_parser_t *parser, token_node_t *node_prev; token_node_t *node, *last = NULL; token_list_t *expansion; + active_list_t *active_initial = parser->active; if (list == NULL) return; @@ -1615,7 +1616,10 @@ _glcpp_parser_expand_token_list (glcpp_parser_t *parser, node = node_prev ? node_prev->next : list->head; } - while (parser->active) + /* Remove any lingering effects of this invocation on the + * active list. That is, pop until the list looks like it did + * at the beginning of this function. */ + while (parser->active && parser->active != active_initial) _parser_active_list_pop (parser); list->non_space_tail = list->tail; _______________________________________________ mesa-commit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/mesa-commit
