This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

target/10194: [3.2 regression] [arm] gcc optimization error with -O2, affecting bison


>Number:         10194
>Category:       target
>Synopsis:       [3.2 regression] [arm] gcc optimization error with -O2, affecting bison
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Sun Mar 23 19:56:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Lukas Geyer <lukas at debian dot org>
>Release:        3.2.3 (Debian prerelease)
>Organization:
The Debian Project
>Environment:
System: Debian GNU/Linux (unstable)
Architecture: arm
host: arm-linux
Thread model: posix
gcc version 3.2.3 20030316 (Debian prerelease)
>Description:
[ Reported to the Debian BTS as report #185903.
  Please CC 185903 at bugs dot debian dot org on replies.
  Log of report can be found at http://bugs.debian.org/185903 ]
	

[gcc-2.95 and gcc-3.3 CVS 20030221 do not show this behaviour]

Lukas Geyer writes:

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:

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.

>How-To-Repeat:
	
>Fix:
	
>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]