Bug#960608: Bison 3.6.1 generates (internal) tokentype and (yyerror) function with same name: _error

2020-05-14 Thread Akim Demaille
Hi!

> Le 14 mai 2020 à 18:47, Chuan-kai Lin  a écrit :
> 
> Hi Akim,
> 
> I am forwarding a bug report that the libexplain and the fhist Debian
> packages fail to build with Bison 3.6.1.
> 
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=960608
> https://tests.reproducible-builds.org/debian/rb-pkg/unstable/amd64/libexplain.html
> 
> I have also attached the build log with this email.  Can you look into
> this issue and see if it is a bug in Bison?  Thanks!

In the log file you sent, I see:

> libtool: compile:  gcc -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 
> -ffile-prefix-map=/build/1st/libexplain-1.4.D001=. -fstack-protector-strong 
> -Wformat -Werror=format-security -Wall -Wextra -Wl,--as-needed -I. -c 
> libexplain/acl_get_file_or_die.c -o libexplain/acl_get_file_or_die.o 
> >/dev/null 2>&1
> bison -y -d  libexplain/acl_grammar.y
> libexplain/acl_grammar.y:62.16-18: warning: POSIX yacc reserves %type to 
> nonterminals [-Wyacc]
>62 | %type  TAG
>   |^~~
> libexplain/acl_grammar.y:63.19-24: warning: POSIX yacc reserves %type to 
> nonterminals [-Wyacc]
>63 | %type  NUMBER
>   |   ^~
> libexplain/acl_grammar.y:66.18-22: warning: POSIX yacc reserves %type to 
> nonterminals [-Wyacc]
>66 | %type  PERMS
>   |  ^
> libexplain/acl_grammar.y:68.17-20: warning: POSIX yacc reserves %type to 
> nonterminals [-Wyacc]
>68 | %type  NAME
>   | ^~~~
> sed -e 's/[yY][yY]/acl_grammar_/g' -e '//d' -e \
>   '//d' -e '//d' y.tab.c > \
>   libexplain/acl_grammar.yacc.c
> sed -e 's/[yY][yY]/acl_grammar_/g' -e \
>   's/Y_TAB_H/libexplain_acl_grammar_YACC_H/g' y.tab.h > \
>   libexplain/acl_grammar.yacc.h

The last two lines are not coming from Bison, and they are smashing
both YYerror and yyerror to acl_grammar_error.  So of course, it fails.

I don't understand why this is done this way.  The grammar file should use
%define api.prefix {acl_grammar_}, or the build system should pass
-Dapi.prefix={acl_grammar_}, or the sed sequence should be less crude.
I would go for

s/yy/acl_grammar_/g; s/YY/ACL_GRAMMAR_/g;

But if this is not ok, and the package still wants to smash yy and YY
to the same string, you could *prepend* this to the sed grammar:

s/YYerror/yyerror_token/g;

so that yyerror becomes acl_grammar_error, and YYerror become
acl_grammar_error_token.  But of course next time we introduce another
symbol which differs by the case of the prefix, the problem will
be back.

Cheers!


Bug#960608: Bison 3.6.1 generates (internal) tokentype and (yyerror) function with same name: _error

2020-05-14 Thread Chuan-kai Lin
Hi Akim,

I am forwarding a bug report that the libexplain and the fhist Debian
packages fail to build with Bison 3.6.1.

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=960608
https://tests.reproducible-builds.org/debian/rb-pkg/unstable/amd64/libexplain.html

I have also attached the build log with this email.  Can you look into
this issue and see if it is a bug in Bison?  Thanks!

Here is the explanation from Andreas Beckmann, who reported the bug:

At least two packages FTBFS with the latest bison with some yyerror related
error message. I had a short look into the libexplain failure and found the
following:

In libexplain/acl_grammar.yacc.c (generated from libexplain/acl_grammar.y),
these bits are new in 3.6.1 (they were not generated by 3.5.3):

...
  enum acl_grammar_tokentype
  {
acl_grammar_EMPTY = -2,
acl_grammar_EOF = 0, /* "end of file"  */
acl_grammar_error = 256, /* error  */
acl_grammar_UNDEF = 257, /* "invalid token"  */
...
  };
...
#define acl_grammar_EOF 0
#define acl_grammar_error 256
#define acl_grammar_UNDEF 257
...

and acl_grammar_error clashes with the existing (generated by 3.6.1 and
3.5.3, in acl_grammar.y this is yyerror())

...
static void
acl_grammar_error(const char *text)
{
...
}

which causes this error during compilation:

y.tab.c:152:27: error: expected identifier or '(' before numeric constant
libexplain/acl_grammar.y:128:1: note: in expansion of macro 'acl_grammar_error'
  128 | yyerror(const char *text)
  | ^
libexplain/acl_grammar.y: In function 'acl_grammar_errorf':
y.tab.c:152:27: error: called object is not a function or function pointer
libexplain/acl_grammar.y:155:5: note: in expansion of macro 'acl_grammar_error'
  155 | yyerror(buf);
  | ^
libexplain/acl_grammar.y: In function 'acl_grammar_parse':
y.tab.c:152:27: error: called object is not a function or function pointer
libexplain/acl_grammar.y:470:13: note: in expansion of macro 'acl_grammar_error'
  470 | yyerror
  | ^~~
y.tab.c:152:27: error: called object is not a function or function pointer
y.tab.c:1720:7: note: in expansion of macro 'acl_grammar_error'
y.tab.c:152:27: error: called object is not a function or function pointer
y.tab.c:1831:3: note: in expansion of macro 'acl_grammar_error'
At top level:
libexplain/acl_grammar.y:105:1: warning: 'result_append' defined but
not used [-Wunused-function]
  105 | result_append(const char *text)
  | ^

This does not look like it is an error in libexplain.
Mon May 11 13:28:49 UTC 2020  I: starting to build libexplain/unstable/amd64 on 
jenkins on '2020-05-11 13:28'
Mon May 11 13:28:49 UTC 2020  I: The jenkins build log is/was available at 
https://jenkins.debian.net/userContent/reproducible/debian/build_service/amd64_14/12752/console.log
Mon May 11 13:28:49 UTC 2020  I: Downloading source for 
unstable/libexplain=1.4.D001-9
--2020-05-11 13:28:50--  
http://deb.debian.org/debian/pool/main/libe/libexplain/libexplain_1.4.D001-9.dsc
Connecting to 78.137.99.97:3128... connected.
Proxy request sent, awaiting response... 200 OK
Length: 2184 (2.1K)
Saving to: ‘libexplain_1.4.D001-9.dsc’

 0K ..100%  190M=0s

2020-05-11 13:28:50 (190 MB/s) - ‘libexplain_1.4.D001-9.dsc’ saved [2184/2184]

Mon May 11 13:28:50 UTC 2020  I: libexplain_1.4.D001-9.dsc
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

Format: 3.0 (quilt)
Source: libexplain
Binary: explain, libexplain-doc, libexplain51, libexplain-dev
Architecture: any all
Version: 1.4.D001-9
Maintainer: Debian QA Group 
Homepage: http://libexplain.sourceforge.net/
Standards-Version: 4.4.0
Vcs-Browser: https://salsa.debian.org/debian/libexplain
Vcs-Git: https://salsa.debian.org/debian/libexplain.git
Build-Depends: bison, debhelper-compat (= 12), ghostscript, groff, libacl1-dev, 
libcap-dev [linux-any], libtool-bin, linux-libc-dev [linux-any], lsof 
[linux-any], netbase
Package-List:
 explain deb devel optional arch=any
 libexplain-dev deb libdevel optional arch=any
 libexplain-doc deb doc optional arch=all
 libexplain51 deb libs optional arch=any
Checksums-Sha1:
 e191e1e7f066f8cefca8d05c846c3a38931d8410 4770006 
libexplain_1.4.D001.orig.tar.gz
 051e4be36c618b454657db790a7a7920704ee513 43992 
libexplain_1.4.D001-9.debian.tar.xz
Checksums-Sha256:
 28863b65eccc74934e237cac41364cb3c1802c36c9e2318ed0417460fee83f80 4770006 
libexplain_1.4.D001.orig.tar.gz
 4ac59e45f82811b8fd0cf519149d224467f25ea212f161a5ac004241f502d543 43992 
libexplain_1.4.D001-9.debian.tar.xz
Files:
 8fabd3de196bde3ca941cd27c029ff8b 4770006 libexplain_1.4.D001.orig.tar.gz
 078b819d14486f28ebab03884dc6b658 43992 libexplain_1.4.D001-9.debian.tar.xz

-BEGIN PGP SIGNATURE-

iQIzBAEBCgAdFiEEfncpR22H1vEdkazLwpPntGGCWs4FAl1yplIACgkQwpPntGGC
Ws6jGg//ZreHxsvjOCNmKJ3RTjNwNEop3ml1HcRdd0YBVLB28zwOLTB6nAaxip6t