bug-bison
[Top][All Lists]
Advanced

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

Bug in src/conflicts.c (AND FIX)


From: osuka
Subject: Bug in src/conflicts.c (AND FIX)
Date: Sat, 16 Mar 2002 04:35:33 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.8) Gecko/20020209

Version: bison 1.34 (verified also in bison 1.32 and bison 1.33)
Machine: Pentium III - Linux Kernel 2.4.17
Compiler: gcc 2.95.3
Command arguments: bison -y -d xftgram.y

Input file: XFree86 4.2.0 distribution, xft library.

Description:  File xftgram.y from the XFree86 4.2.0 sources causes
"segmentation fault" with no further information.

Explanation:

Hi, I have found a very weird bug while compiling XFree86 4.2.0.

When compiling xft library XFree86 calls bison with file xftgram.y. This includes several files which I am not smart enough to track, sorry. If you want I can send you the whole conflicting directory.

Using gdb I found the SEGFAULT was triggered on file conflict.c line 43.


Patch:

I have tracked down the error and find a one-line patch.

*** conflicts.c Mon Jan  7 09:42:43 2002
--- /usr/src/bison-1.34/src/conflicts.c Fri Mar 15 04:11:52 2002
*************** static inline void
*** 41,48 ****
 log_resolution (int state, int LAno, int token, char *resolution)
 {
   obstack_fgrow4 (&output_obstack,
!                 _("\
! Conflict in state %d between rule %d and token %s resolved as %s.\n"),
                 state, LAruleno[LAno], tags[token], resolution);
 }

--- 41,47 ----
 log_resolution (int state, int LAno, int token, char *resolution)
 {
   obstack_fgrow4 (&output_obstack,
! _(" Conflict in state %d between rule %d and token %s resolved
as %s.\n"),
                 state, LAruleno[LAno], tags[token], resolution);
 }



-------------------------------------------------------------------

Could you check this?

I find this to be a very simple fix that removes a possible segfault
and I foresee no other interactions. Please apply it.

Without the patch the user does not know what is going wrong and
it is very frustating (that's why I tried to find a fix). Bison
breaks without printing any message other than the segfault itself.

As it seems, truncating the string literal that is passed to
obstack_fgrow4 nested twice macro breaks the generated code.
I tried compilation with various options but did not obtain valid
code until I applied the patch. I also tried several other options,
like changing the call to obstack_fgrow4 with a simple fprintf
and it also worked.

There are other portions of the code using the same truncation but
without the severe macro nesting that causes the segfault and do
not seem affected.

This looks like a gcc bug. But this change allowed me to fully
compile XFree86 4.2.0 and it is a very small change that can
help others.

My machine seems to be sane apart from this (at least compiles
everything, including XFree86).

Thanks.
Oscar

PS: This is my first reporting of a bug/fix so if I did anything
wrong or if you would prefer some other format for
the bug report please tell me, I am willing to help.

*** conflicts.c Mon Jan  7 09:42:43 2002
--- /usr/src/bison-1.34/src/conflicts.c Fri Mar 15 04:11:52 2002
*************** static inline void
*** 41,48 ****
  log_resolution (int state, int LAno, int token, char *resolution)
  {
    obstack_fgrow4 (&output_obstack,
!                 _("\
! Conflict in state %d between rule %d and token %s resolved as %s.\n"),
                  state, LAruleno[LAno], tags[token], resolution);
  }
  
--- 41,47 ----
  log_resolution (int state, int LAno, int token, char *resolution)
  {
    obstack_fgrow4 (&output_obstack,
!                 _(" Conflict in state %d between rule %d and token %s 
resolved as %s.\n"),
                  state, LAruleno[LAno], tags[token], resolution);
  }
  

reply via email to

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