GNOME Bugzilla – Bug 712679
parse: prototype-mismatch
Last modified: 2013-11-29 19:03:50 UTC
just tracked down a segfault: gstreamer/gst/parse$ grep "int.*yylex_init " *.c grammar.tab.c:int priv_gst_parse_yylex_init (yyscan_t scanner); lex.priv_gst_parse_yy.c:int priv_gst_parse_yylex_init (yyscan_t* scanner); funny/scary that it works most of the time. patch will be attached in a minute (or two ;).
Created attachment 260241 [details] [review] fix segfaulting prototype mismatch
Created attachment 260264 [details] [review] 0002-clean up Makefile after fixing the bug to be applied after the other patch. We no longer need to avoid -Werror and -Wall. What a surprise.. ;)
I merged your two patches and committed them with two small modifications. I put the include after the part about debugging so that YYDEBUG is set to 1 if debugging is enabled. Then the include file always defines YYDEBUG (to 0 if it was not defined), so actually check for the content. commit 56d74ddb644052dc76d97c22b9f284cc0c7fe35a Author: Fabian Kirsch <derFakir@web.de> Date: Tue Nov 19 15:03:35 2013 +0100 parse: fix segfaulting prototype-mismatch Now YYDEBUG is always set, so check it's value https://bugzilla.gnome.org/show_bug.cgi?id=712679
this commit breaks the build http://arracacha.collabora.co.uk:8080/job/GStreamer-master/385/console Note that it succeeds one some setups but fails on other (that machines is a up to date Ubuntu 12.04 but I also have it failing on a 12.10).
the missing prototypes are in the generated header: $ grep yy.*_col parse_lex.h #define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) int yy_bs_column; /**< The column count. */ int priv_gst_parse_yyget_column (yyscan_t yyscanner ); void priv_gst_parse_yyset_column (int column_no ,yyscan_t yyscanner ); But lex.priv_gst_parse_yy.c does not include it: $ grep parse_lex lex.priv_gst_parse_yy.c $ instead flex already weaves it in: $ grep -n yyget_col *.c lex.priv_gst_parse_yy.c:1019:int priv_gst_parse_yyget_column (yyscan_t yyscanner ); lex.priv_gst_parse_yy.c:2189:int priv_gst_parse_yyget_column (yyscan_t yyscanner) what version of flex do you have? $ flex -V flex 2.5.35 if i include parse_lex.h in parse.l, gcc complains later.
the missing prototypes are in the generated header: $ grep yy.*_col parse_lex.h #define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) int yy_bs_column; /**< The column count. */ int priv_gst_parse_yyget_column (yyscan_t yyscanner ); void priv_gst_parse_yyset_column (int column_no ,yyscan_t yyscanner ); But lex.priv_gst_parse_yy.c does not include it: $ grep parse_lex lex.priv_gst_parse_yy.c $ instead flex already weaves it in: $ grep -n yyget_col *.c lex.priv_gst_parse_yy.c:1019:int priv_gst_parse_yyget_column (yyscan_t yyscanner ); lex.priv_gst_parse_yy.c:2189:int priv_gst_parse_yyget_column (yyscan_t yyscanner) what version of flex do you have? $ flex -V flex 2.5.35 if i include parse_lex.h in parse.l, gcc complains later. if we get [-Werror=redundant-decls] out of the make, than we can include parse_lex.h in parse.l
Ubuntu 12.10: $ grep yy.*_col parse_lex.h #define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) int yy_bs_column; /**< The column count. */ $ grep parse_lex lex.priv_gst_parse_yy.c $ grep -n yyget_col *.c lex.priv_gst_parse_yy.c:2185:int priv_gst_parse_yyget_column (yyscan_t yyscanner) $ flex -V flex 2.5.35 fedora 19 (where it works): $ grep yy.*_col parse_lex.h #define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) int yy_bs_column; /**< The column count. */ int priv_gst_parse_yyget_column (yyscan_t yyscanner ); void priv_gst_parse_yyset_column (int column_no ,yyscan_t yyscanner ); $ grep parse_lex lex.priv_gst_parse_yy.c $ grep -n yyget_col *.c lex.priv_gst_parse_yy.c:1011:int priv_gst_parse_yyget_column (yyscan_t yyscanner ); lex.priv_gst_parse_yy.c:2177:int priv_gst_parse_yyget_column (yyscan_t yyscanner) $ flex -V flex 2.5.37
@fabian: which distro are you using ?
debian wheezy
i asked on flex-help@lists.sourceforge.net to have a look at this. my minimal testcase comes here: ---8<--- /tmp/flex$ flex -V flex 2.5.35 /tmp/flex$ cat > testfile.l << "EOT" > %{ > %} > > %x value > %option noyywrap > %option nounput > %option reentrant > %option bison-bridge > %option never-interactive > %option noinput > %% > > EOT /tmp/flex$ flex testfile.l /tmp/flex$ grep et_col * lex.yy.c:int yyget_column (yyscan_t yyscanner ); lex.yy.c:void yyset_column (int column_no ,yyscan_t yyscanner ); lex.yy.c:int yyget_column (yyscan_t yyscanner) lex.yy.c:void yyset_column (int column_no , yyscan_t yyscanner) [..] --->8---
Yes, these protoypes were added in flex 2.5.36... but debian patched it back into their 2.5.35 version. Ubuntu had this patch in 12.10, but it's not in their 12.04 version that Edward's using.
Fixed again, by adding the prototypes manually if they were not already there commit 3c4d54fd885ee352d16cdcce60323f01a22721e1 Author: Olivier Crête <olivier.crete@collabora.com> Date: Fri Nov 29 14:00:35 2013 -0500 parse: Manually insert priv_gst_parse_yyget/set_column prototypes for older Older versions of flex (before 2.5.36) don't add the prototype, so it must be added manually. We can't check by the version number, because Debian/Ubun patched it into their 2.5.35 at some point.