Skip to contentSkip to conversation

Fix filter parser segmentation fault with bison 3.0

PATCH Yannick Brosseau 3 participants 4 messages Aug 16, 2013 2 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Also tested on CentOS6 with bison 2.4

Quoted 77 lines · Zifei Tong

Replace deprecated YYLEX_PARAM with %lex-param

Tested with bison 2.7 and bison 3.0

---
 src/lib/lttng-ctl/filter/filter-ast.h    |  3 ---
 src/lib/lttng-ctl/filter/filter-parser.y | 13 +++++++------
 2 files changed, 7 insertions(+), 9 deletions(-)
src/lib/lttng-ctl/filter/filter-ast.h +0 -3
index 4fb60d0..405c668 100644
@@ -39,9 +39,6 @@
 // data is a pointer to a 'SParserParam' structure
 //#define YYPARSE_PARAM	parser_ctx
 
-// the argument for the 'yylex' function
-#define YYLEX_PARAM	((struct filter_parser_ctx *) parser_ctx)->scanner
-
 #ifndef YY_TYPEDEF_YY_SCANNER_T
 #define YY_TYPEDEF_YY_SCANNER_T
 typedef void* yyscan_t;
src/lib/lttng-ctl/filter/filter-parser.y +7 -6
index 3f30134..29e2866 100644
@@ -40,9 +40,9 @@ LTTNG_HIDDEN
 int filter_parser_debug = 0;
 
 LTTNG_HIDDEN
-int yyparse(struct filter_parser_ctx *parser_ctx);
+int yyparse(struct filter_parser_ctx *parser_ctx, yyscan_t scanner);
 LTTNG_HIDDEN
-int yylex(union YYSTYPE *yyval, struct filter_parser_ctx *parser_ctx);
+int yylex(union YYSTYPE *yyval, yyscan_t scanner);
 LTTNG_HIDDEN
 int yylex_init_extra(struct filter_parser_ctx *parser_ctx, yyscan_t * ptr_yy_globals);
 LTTNG_HIDDEN
@@ -188,7 +188,7 @@ static struct filter_node *make_op_node(struct filter_parser_ctx *scanner,
 }
 
 LTTNG_HIDDEN
-void yyerror(struct filter_parser_ctx *parser_ctx, const char *str)
+void yyerror(struct filter_parser_ctx *parser_ctx, yyscan_t scanner, const char *str)
 {
 	fprintf(stderr, "error %s\n", str);
 }
@@ -201,7 +201,7 @@ int yywrap(void)
 
 #define parse_error(parser_ctx, str)				\
 do {								\
-	yyerror(parser_ctx, YY_("parse error: " str "\n"));	\
+	yyerror(parser_ctx, parser_ctx->scanner, YY_("parse error: " str "\n"));	\
 	YYERROR;						\
 } while (0)
 
@@ -238,7 +238,7 @@ static void filter_ast_free(struct filter_ast *ast)
 LTTNG_HIDDEN
 int filter_parser_ctx_append_ast(struct filter_parser_ctx *parser_ctx)
 {
-	return yyparse(parser_ctx);
+	return yyparse(parser_ctx, parser_ctx->scanner);
 }
 
 LTTNG_HIDDEN
@@ -301,7 +301,8 @@ void filter_parser_ctx_free(struct filter_parser_ctx *parser_ctx)
 %define api.pure
 	/* %locations */
 %parse-param {struct filter_parser_ctx *parser_ctx}
-%lex-param {struct filter_parser_ctx *parser_ctx}
+%parse-param {yyscan_t scanner}
+%lex-param {yyscan_t scanner}
 %start translation_unit
 %token CHARACTER_CONSTANT_START SQUOTE STRING_LITERAL_START DQUOTE
 %token ESCSEQ CHAR_STRING_TOKEN
#2 lore raw
In reply to a message not in the archive
Quoted 5 lines · * Zifei Tong ([email protected]) wrote:

Replace deprecated YYLEX_PARAM with %lex-param

Tested with bison 2.7 and bison 3.0

David, can you take care of merging it ?

Thanks,

Mathieu

Quoted 80 lines
---
 src/lib/lttng-ctl/filter/filter-ast.h    |  3 ---
 src/lib/lttng-ctl/filter/filter-parser.y | 13 +++++++------
 2 files changed, 7 insertions(+), 9 deletions(-)
src/lib/lttng-ctl/filter/filter-ast.h +0 -3
index 4fb60d0..405c668 100644
@@ -39,9 +39,6 @@
 // data is a pointer to a 'SParserParam' structure
 //#define YYPARSE_PARAM	parser_ctx
 
-// the argument for the 'yylex' function
-#define YYLEX_PARAM	((struct filter_parser_ctx *) parser_ctx)->scanner
-
 #ifndef YY_TYPEDEF_YY_SCANNER_T
 #define YY_TYPEDEF_YY_SCANNER_T
 typedef void* yyscan_t;
src/lib/lttng-ctl/filter/filter-parser.y +7 -6
index 3f30134..29e2866 100644
@@ -40,9 +40,9 @@ LTTNG_HIDDEN
 int filter_parser_debug = 0;
 
 LTTNG_HIDDEN
-int yyparse(struct filter_parser_ctx *parser_ctx);
+int yyparse(struct filter_parser_ctx *parser_ctx, yyscan_t scanner);
 LTTNG_HIDDEN
-int yylex(union YYSTYPE *yyval, struct filter_parser_ctx *parser_ctx);
+int yylex(union YYSTYPE *yyval, yyscan_t scanner);
 LTTNG_HIDDEN
 int yylex_init_extra(struct filter_parser_ctx *parser_ctx, yyscan_t * ptr_yy_globals);
 LTTNG_HIDDEN
@@ -188,7 +188,7 @@ static struct filter_node *make_op_node(struct filter_parser_ctx *scanner,
 }
 
 LTTNG_HIDDEN
-void yyerror(struct filter_parser_ctx *parser_ctx, const char *str)
+void yyerror(struct filter_parser_ctx *parser_ctx, yyscan_t scanner, const char *str)
 {
 	fprintf(stderr, "error %s\n", str);
 }
@@ -201,7 +201,7 @@ int yywrap(void)
 
 #define parse_error(parser_ctx, str)				\
 do {								\
-	yyerror(parser_ctx, YY_("parse error: " str "\n"));	\
+	yyerror(parser_ctx, parser_ctx->scanner, YY_("parse error: " str "\n"));	\
 	YYERROR;						\
 } while (0)
 
@@ -238,7 +238,7 @@ static void filter_ast_free(struct filter_ast *ast)
 LTTNG_HIDDEN
 int filter_parser_ctx_append_ast(struct filter_parser_ctx *parser_ctx)
 {
-	return yyparse(parser_ctx);
+	return yyparse(parser_ctx, parser_ctx->scanner);
 }
 
 LTTNG_HIDDEN
@@ -301,7 +301,8 @@ void filter_parser_ctx_free(struct filter_parser_ctx *parser_ctx)
 %define api.pure
 	/* %locations */
 %parse-param {struct filter_parser_ctx *parser_ctx}
-%lex-param {struct filter_parser_ctx *parser_ctx}
+%parse-param {yyscan_t scanner}
+%lex-param {yyscan_t scanner}
 %start translation_unit
 %token CHARACTER_CONSTANT_START SQUOTE STRING_LITERAL_START DQUOTE
 %token ESCSEQ CHAR_STRING_TOKEN
Signature · 7 lines
1.8.3.4


_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Signature · 3 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

A message that is not in the archive (sent off-list or not yet received): 20130816152331.GA28878@Krystal

#4 lore raw

Ya sure! I was waiting for you Ack :)

David

Mathieu Desnoyers:

Quoted 96 lines · * Zifei Tong ([email protected]) wrote:
Quoted 5 lines

Replace deprecated YYLEX_PARAM with %lex-param

Tested with bison 2.7 and bison 3.0

David, can you take care of merging it ?

Thanks,

Mathieu

Quoted 80 lines
---
 src/lib/lttng-ctl/filter/filter-ast.h    |  3 ---
 src/lib/lttng-ctl/filter/filter-parser.y | 13 +++++++------
 2 files changed, 7 insertions(+), 9 deletions(-)
src/lib/lttng-ctl/filter/filter-ast.h +0 -3
index 4fb60d0..405c668 100644
@@ -39,9 +39,6 @@
 // data is a pointer to a 'SParserParam' structure
 //#define YYPARSE_PARAM	parser_ctx
 
-// the argument for the 'yylex' function
-#define YYLEX_PARAM	((struct filter_parser_ctx *) parser_ctx)->scanner
-
 #ifndef YY_TYPEDEF_YY_SCANNER_T
 #define YY_TYPEDEF_YY_SCANNER_T
 typedef void* yyscan_t;
src/lib/lttng-ctl/filter/filter-parser.y +7 -6
index 3f30134..29e2866 100644
@@ -40,9 +40,9 @@ LTTNG_HIDDEN
 int filter_parser_debug = 0;
 
 LTTNG_HIDDEN
-int yyparse(struct filter_parser_ctx *parser_ctx);
+int yyparse(struct filter_parser_ctx *parser_ctx, yyscan_t scanner);
 LTTNG_HIDDEN
-int yylex(union YYSTYPE *yyval, struct filter_parser_ctx *parser_ctx);
+int yylex(union YYSTYPE *yyval, yyscan_t scanner);
 LTTNG_HIDDEN
 int yylex_init_extra(struct filter_parser_ctx *parser_ctx, yyscan_t * ptr_yy_globals);
 LTTNG_HIDDEN
@@ -188,7 +188,7 @@ static struct filter_node *make_op_node(struct filter_parser_ctx *scanner,
 }
 
 LTTNG_HIDDEN
-void yyerror(struct filter_parser_ctx *parser_ctx, const char *str)
+void yyerror(struct filter_parser_ctx *parser_ctx, yyscan_t scanner, const char *str)
 {
 	fprintf(stderr, "error %s\n", str);
 }
@@ -201,7 +201,7 @@ int yywrap(void)
 
 #define parse_error(parser_ctx, str)				\
 do {								\
-	yyerror(parser_ctx, YY_("parse error: " str "\n"));	\
+	yyerror(parser_ctx, parser_ctx->scanner, YY_("parse error: " str "\n"));	\
 	YYERROR;						\
 } while (0)
 
@@ -238,7 +238,7 @@ static void filter_ast_free(struct filter_ast *ast)
 LTTNG_HIDDEN
 int filter_parser_ctx_append_ast(struct filter_parser_ctx *parser_ctx)
 {
-	return yyparse(parser_ctx);
+	return yyparse(parser_ctx, parser_ctx->scanner);
 }
 
 LTTNG_HIDDEN
@@ -301,7 +301,8 @@ void filter_parser_ctx_free(struct filter_parser_ctx *parser_ctx)
 %define api.pure
 	/* %locations */
 %parse-param {struct filter_parser_ctx *parser_ctx}
-%lex-param {struct filter_parser_ctx *parser_ctx}
+%parse-param {yyscan_t scanner}
+%lex-param {yyscan_t scanner}
 %start translation_unit
 %token CHARACTER_CONSTANT_START SQUOTE STRING_LITERAL_START DQUOTE
 %token ESCSEQ CHAR_STRING_TOKEN
Signature · 7 lines
1.8.3.4


_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
#5 lore raw
In reply to a message not in the archive

merged as:

commit 9039edd4983b46fc45dae7ed42396ef7f7e5635a

Author: Zifei Tong <[email protected]>
Date:   Fri Aug 16 16:52:21 2013 -0400

Fix filter parser segmentation fault with bison 3.0

Replace deprecated YYLEX_PARAM with %lex-param

Tested with bison 2.4, 2.5, 2.7 and 3.0.

and backported to stable-2.2

Quoted 85 lines · * Zifei Tong ([email protected]) wrote:

Replace deprecated YYLEX_PARAM with %lex-param

Tested with bison 2.7 and bison 3.0

---
 src/lib/lttng-ctl/filter/filter-ast.h    |  3 ---
 src/lib/lttng-ctl/filter/filter-parser.y | 13 +++++++------
 2 files changed, 7 insertions(+), 9 deletions(-)
src/lib/lttng-ctl/filter/filter-ast.h +0 -3
index 4fb60d0..405c668 100644
@@ -39,9 +39,6 @@
 // data is a pointer to a 'SParserParam' structure
 //#define YYPARSE_PARAM	parser_ctx
 
-// the argument for the 'yylex' function
-#define YYLEX_PARAM	((struct filter_parser_ctx *) parser_ctx)->scanner
-
 #ifndef YY_TYPEDEF_YY_SCANNER_T
 #define YY_TYPEDEF_YY_SCANNER_T
 typedef void* yyscan_t;
src/lib/lttng-ctl/filter/filter-parser.y +7 -6
index 3f30134..29e2866 100644
@@ -40,9 +40,9 @@ LTTNG_HIDDEN
 int filter_parser_debug = 0;
 
 LTTNG_HIDDEN
-int yyparse(struct filter_parser_ctx *parser_ctx);
+int yyparse(struct filter_parser_ctx *parser_ctx, yyscan_t scanner);
 LTTNG_HIDDEN
-int yylex(union YYSTYPE *yyval, struct filter_parser_ctx *parser_ctx);
+int yylex(union YYSTYPE *yyval, yyscan_t scanner);
 LTTNG_HIDDEN
 int yylex_init_extra(struct filter_parser_ctx *parser_ctx, yyscan_t * ptr_yy_globals);
 LTTNG_HIDDEN
@@ -188,7 +188,7 @@ static struct filter_node *make_op_node(struct filter_parser_ctx *scanner,
 }
 
 LTTNG_HIDDEN
-void yyerror(struct filter_parser_ctx *parser_ctx, const char *str)
+void yyerror(struct filter_parser_ctx *parser_ctx, yyscan_t scanner, const char *str)
 {
 	fprintf(stderr, "error %s\n", str);
 }
@@ -201,7 +201,7 @@ int yywrap(void)
 
 #define parse_error(parser_ctx, str)				\
 do {								\
-	yyerror(parser_ctx, YY_("parse error: " str "\n"));	\
+	yyerror(parser_ctx, parser_ctx->scanner, YY_("parse error: " str "\n"));	\
 	YYERROR;						\
 } while (0)
 
@@ -238,7 +238,7 @@ static void filter_ast_free(struct filter_ast *ast)
 LTTNG_HIDDEN
 int filter_parser_ctx_append_ast(struct filter_parser_ctx *parser_ctx)
 {
-	return yyparse(parser_ctx);
+	return yyparse(parser_ctx, parser_ctx->scanner);
 }
 
 LTTNG_HIDDEN
@@ -301,7 +301,8 @@ void filter_parser_ctx_free(struct filter_parser_ctx *parser_ctx)
 %define api.pure
 	/* %locations */
 %parse-param {struct filter_parser_ctx *parser_ctx}
-%lex-param {struct filter_parser_ctx *parser_ctx}
+%parse-param {yyscan_t scanner}
+%lex-param {yyscan_t scanner}
 %start translation_unit
 %token CHARACTER_CONSTANT_START SQUOTE STRING_LITERAL_START DQUOTE
 %token ESCSEQ CHAR_STRING_TOKEN
Signature · 7 lines
1.8.3.4


_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Signature · 3 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com