Bug#185903: [arm] gcc optimization error with -O2, affecting bison
Package: gcc-3.2
Version: 1:3.2.3ds2-0pre3
Severity: important
Hi,
I have been unable to cook up a short testcase, mainly due to bad
connectivity and lack of experience. However, bison-1.875a gets
miscompiled on arm with -O2, it seems to compile correctly with
-O1. My experiments where done in a sid chroot on debussy, so I used
the available versions in sid. Here are the relevant code sections and
what gdb shows.
src/reader.c:
void
epilogue_augment (const char *epilogue, location loc)
{
char *extension = NULL;
obstack_fgrow1 (&muscle_obstack, "]b4_syncline([[%d]], [[", loc.start.line);
MUSCLE_OBSTACK_SGROW (&muscle_obstack,
quotearg_style (c_quoting_style, loc.start.file));
obstack_sgrow (&muscle_obstack, "]])[\n");
obstack_sgrow (&muscle_obstack, epilogue);
obstack_1grow (&muscle_obstack, 0);
extension = obstack_finish (&muscle_obstack);
muscle_grow ("epilogue", extension, "");
obstack_free (&muscle_obstack, extension);
}
lib/quotearg.c:
char *
quotearg_n_style (int n, enum quoting_style s, char const *arg)
{
struct quoting_options const o = quoting_options_from_style (s);
return quotearg_n_options (n, arg, SIZE_MAX, &o);
}
char *
quotearg_style (enum quoting_style s, char const *arg)
{
return quotearg_n_style (0, s, arg);
}
gdb backtrace:
#0 0x00027964 in quotearg_buffer_restyled (buffer=0x3d8f4 "\"YPE_NAME_OR_ID",
buffersize=256, arg=0x2c <Address 0x2c out of bounds>, argsize=4294967295,
quoting_style=c_quoting_style, o=0xbfffc510) at quotearg.c:481
#1 0x00027a64 in quotearg_buffer (buffer=0x3d8f4 "\"YPE_NAME_OR_ID",
buffersize=0, arg=0x2c <Address 0x2c out of bounds>, argsize=4294967295,
o=0xbfffc510) at quotearg.c:503
#2 0x00027b38 in quotearg_n_options (n=0,
arg=0x2c <Address 0x2c out of bounds>, argsize=4294967295,
options=0xbfffc510) at quotearg.c:560
#3 0x00027c84 in quotearg_n_style (n=0, s=256,
arg=0x2c <Address 0x2c out of bounds>) at quotearg.c:600
#4 0x00018a38 in epilogue_augment (
epilogue=0x950e0 "\n\n/*@@-redecl@@*/\nextern char *yytext;\n/*@@=redecl@@*/\n\n# include \"bison.reset\"\n\nvoid yyerror (/*@@unused@@*/ char *s) \n{\n static bool givehint = FALSE;\n\n if (context_inIterDef ())\n {\n llerr"..., loc=
{start = {file = 0x400e8d80 "", line = 0, column = 4096}, end = {file =
0x4013eb24 "0\n\022", line = 249784, column = 280128}}) at reader.c:94
#5 0x00015c0c in gram_parse () at parse-gram.y:399
Looking at this backtrace, it seems that the pointer loc.start.file is
passed incorrectly to quotearg_n_style, optimizing away
quotearg_style, subsequently causing a segfault. I can supply the .y
file which causes the segfault, if it would be helpful, or you can
just get from the source of lclint, it is cgrammar.y, see also
http://buildd.debian.org/fetch.php?&pkg=lclint&ver=1%3A2.4b-1.4&arch=arm&stamp=1048326775&file=log&as=raw
Best regards,
Lukas
P.S.: I recommend compiling the bison package with -O1 on arm, until
this issue is resolved. I will separately file a bug against bison
proposing this.
--
Give a man an answer, and he's satisfied today. Teach him to program,
and he will be frustrated for the rest of his life.
Reply to: