This is the mail archive of the gcc-bugs@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]

[Bug preprocessor/15307] Preprocessor ICE on invalid input


------- Additional Comments From nisse at lysator dot liu dot se  2004-05-06 15:13 -------
Strange. I've now double checked that the file in the attachment is
the same one as I have locally. And I built gcc with plain ./configure
&& make bootstrap && make install, no special options.

Output from "gcc -v -DWANT_CHECKS=1 -E bug.c ":

Reading specs from /usr/local/lib/gcc/i686-pc-linux-gnu/3.4.0/specs
Configured with: /usr/local/src/gcc-3.4.0/configure 
Thread model: posix
gcc version 3.4.0
 /usr/local/libexec/gcc/i686-pc-linux-gnu/3.4.0/cc1 -E -quiet -v -DWANT_CHECKS=1
bug.c -mtune=pentiumpro
ignoring nonexistent directory "NONE/include"
ignoring nonexistent directory
"/usr/local/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/local/lib/gcc/i686-pc-linux-gnu/3.4.0/include
 /usr/include
End of search list.
# 1 "bug.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "bug.c"


static void
hbgcd2 (mp_limb_t ah, mp_limb_t al, mp_limb_t bh, mp_limb_t bl, unsigned k,
       struct bgcd_matrix1 *m)
{
# 30 "bug.c"
  static const unsigned char zerobits_table[0x16] =
    { 0,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 };

  mp_limb_signed_t r00, r01, r10, r11;
  unsigned j;

  ASSERT_ALWAYS (ODD (al));
  ASSERT_ALWAYS (!ODD (bl));
  ASSERT_ALWAYS (k <= SMALL_STEP_BITS);

  r00 = r11 = 1;
  r01 = r10 = 0;
  j = 0;


  while (k - j > GMP_NUMB_BITS / 2)
    {


      unsigned bits;

      mp_limb_t t0, t1;
      mp_limb_signed_t q;

      TRACE (printf ("hgcd2: a = %8lx %08lx\n"
       "       b = %8lx %08lx\n",
       ah, al, bh, bl));

      ASSERT_ALWAYS (ODD (al));
bug.c:0: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

Running cc1 in gdb, run -E -quiet -v -DWANT_CHECKS=1
/home/nisse/hack/gcd/bug.c -mtune=pentiumpro, I get the backtrace

#0  0x0808baf0 in lex_number (pfile=0x8431258, number=0x8447000)
    at /usr/local/src/gcc-3.4.0/gcc/cpplex.c:528
#1  0x0808c24c in _cpp_lex_direct (pfile=0x8431258)
    at /usr/local/src/gcc-3.4.0/gcc/cpplex.c:1042
#2  0x0808c70c in _cpp_lex_token (pfile=0x8431258)
    at /usr/local/src/gcc-3.4.0/gcc/cpplex.c:710
#3  0x0808d26c in cpp_get_token (pfile=0x8431258)
    at /usr/local/src/gcc-3.4.0/gcc/cppmacro.c:1061
#4  0x0808da31 in cpp_get_token (pfile=0x8431258)
    at /usr/local/src/gcc-3.4.0/gcc/cppmacro.c:578
#5  0x08084b78 in preprocess_file (pfile=0x8431258)
    at /usr/local/src/gcc-3.4.0/gcc/c-ppoutput.c:135
#6  0x0807f45f in c_common_init ()
    at /usr/local/src/gcc-3.4.0/gcc/c-opts.c:1195
#7  0x08086d6e in c_objc_common_init ()
    at /usr/local/src/gcc-3.4.0/gcc/c-objc-common.c:166
#8  0x08275f59 in toplev_main (argc=1, argv=0x0)
    at /usr/local/src/gcc-3.4.0/gcc/toplev.c:4527
#9  0x0809962e in main (argc=1, argv=0x1)
    at /usr/local/src/gcc-3.4.0/gcc/main.c:35

The number argument to lex_number is invalid according to gdb ("Cannot
access memory at address 0x8447000"). This comes ultimately from

  cpp_token *result = pfile->cur_token++;

at the start of _cpp_lex_direct.

I don't have much clue on how to debug this. I could try to reduce the
testcase further.

Note that the -DWANT_CHECKS=1 on the command line is essential.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15307


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