help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bison 1.29 bug+lack


From: wwp
Subject: bison 1.29 bug+lack
Date: Wed, 24 Oct 2001 16:50:31 +0200

Hello dear bison maintainers,


I've just installed bison 1.29 in replacement of 1.28 I was previously using.
I noticed 2 bugs that lead bison to crash or to produce non compilable code
(they are mainly due to a lack of control in their running context).

I ride bison 1.29 on a GNU/linux box, i686, glibc2.1, gcc 2.91.66.


1) the crash:

Compiling a grammar that as a { missing produces a segfault., whereas 1.28 was
'only' reporting some errors. Please consider the sample grammar file attached.

'bison.129 foo.y' says:
        Segmentation fault
whereas 'bison.128 foo.y' says:
        foo.y:9: invalid input: }
        foo.y:10: invalid input: ;
which is prettier IMHO even if it's not enough helpful nor precise regarding to
the error location/type.

You'll find gdb's output in an joined file.


2) the bug that produces non-compilable code:

Using 'bison -d <file>', the <file>.h file contains 2 lines like the following:
        #ifndef FOO_TAB_H
        # define FOO_TAB_H
okay it works.
But when <file> contains a complete path to the file, here are the 2 lines 
generated:
        #ifndef /THE/PATH/TO/FOO_TAB_H
        # define /THE/PATH/TO/FOO_TAB_H
sure, it won't compile :).

There are other cases in where the macro name can't compile ('bison -d 1-a.y' 
for
instance).

This stuff is done in the function compute_header_macro() in src/files.c. It 
replaces
'.' by '_' and does a toupper() of a-z.

So there're 2 solutions to this:
 - macro name could be based upon the _REAL_ basename of the file (I mean 
without
   the path),
 - the macro name generation must be compliant to the macro naming rules: this 
means
  [a-z_][a-z0-9_]*. The current implementation in 1.29 fails to at least 2 
points of this
  rule: it supports macronames starting with 0-9 and macronames containing any 
char
  other than '_'.

The first point is optional and in fact doesn't really care, even if more 
secure towards
the unicity of the macro name to let the pathname.

You'll find as a joined part a patch that fix the 2nd point or this 2nd bug.
Sure there are many ways to do the same (and some more optimized ones), but it's
compliant to the rules and secure, it encapsulates with '_' then convert a-z to 
A-Z,
leave 0-9 as is and move other chars to '_', roughly.


HIH


Warm regards,

-- 
wwp

Attachment: foo.y
Description: Binary data

Attachment: bison-1.29-fixed_header_generation.patch
Description: Binary data

Attachment: gdb_output.txt
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]