Ian Jackson
2011-Mar-02 14:35 UTC
[Xen-devel] [PATCH] libxl: correctly initialise yylineno
Sometimes xl would read an uninitialised variable when printing error messages, resulting in things like this: /etc/xen/thing.cfg:1030057088: config parsing error near `"ws08r2-x64-2'': lexical error This is because yylineno is a variable inside the scanner created by yylex_init, but it is not initialised by yylex_init. (Debian bug #616099.) On the way I discovered a lot of complication to do with the calling convention between bison and flex in reentrant parsers/scanners which use locations (Debian bug #616100) but as the above change makes the current code in xen-unstable work I don''t propose to do anything else about that now in our tree. Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com> --- tools/libxl/libxlu_cfg.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/tools/libxl/libxlu_cfg.c b/tools/libxl/libxlu_cfg.c index 663fdf9..f947c21 100644 --- a/tools/libxl/libxlu_cfg.c +++ b/tools/libxl/libxlu_cfg.c @@ -43,6 +43,9 @@ static void ctx_dispose(CfgParseContext *ctx) { static void parse(CfgParseContext *ctx) { /* On return, ctx.err will be updated with the error status. */ int r; + + xlu__cfg_yyset_lineno(1, ctx->scanner); + r= xlu__cfg_yyparse(ctx); if (r) assert(ctx->err); -- 1.5.6.5 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Mar-02 17:16 UTC
Re: [Xen-devel] [PATCH] libxl: correctly initialise yylineno
On Wed, 2011-03-02 at 14:35 +0000, Ian Jackson wrote:> Sometimes xl would read an uninitialised variable when printing error > messages, resulting in things like this: > /etc/xen/thing.cfg:1030057088: config parsing error near `"ws08r2-x64-2'': lexical error > > This is because yylineno is a variable inside the scanner created by > yylex_init, but it is not initialised by yylex_init. > (Debian bug #616099.) > > On the way I discovered a lot of complication to do with the calling > convention between bison and flex in reentrant parsers/scanners which > use locations (Debian bug #616100) but as the above change makes the > current code in xen-unstable work I don''t propose to do anything else > about that now in our tree. > > Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>This fixes the issue I was having: # xl cr -d /root/x Parsing config file /root/x /root/x:24: config parsing error near `"ws08r2-x64-2'': lexical error Failed to parse config file: Invalid argument Where line 24 does indeed contain an error. Tested/Acked-by: Ian Campbell <ian.campbell@citrix.com>> --- > tools/libxl/libxlu_cfg.c | 3 +++ > 1 files changed, 3 insertions(+), 0 deletions(-) > > diff --git a/tools/libxl/libxlu_cfg.c b/tools/libxl/libxlu_cfg.c > index 663fdf9..f947c21 100644 > --- a/tools/libxl/libxlu_cfg.c > +++ b/tools/libxl/libxlu_cfg.c > @@ -43,6 +43,9 @@ static void ctx_dispose(CfgParseContext *ctx) { > static void parse(CfgParseContext *ctx) { > /* On return, ctx.err will be updated with the error status. */ > int r; > + > + xlu__cfg_yyset_lineno(1, ctx->scanner); > + > r= xlu__cfg_yyparse(ctx); > if (r) assert(ctx->err); >_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Jackson
2011-Mar-03 17:11 UTC
Re: [Xen-devel] [PATCH] libxl: correctly initialise yylineno
Ian Campbell writes ("Re: [Xen-devel] [PATCH] libxl: correctly initialise yylineno"):> On Wed, 2011-03-02 at 14:35 +0000, Ian Jackson wrote: > > Sometimes xl would read an uninitialised variable when printing error > > messages, resulting in things like this:...>> This fixes the issue I was having:Thanks for the report and review; committed. Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel