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

[committed] Fix crash in selftest::test_lexer_string_locations_ucn4 (PR bootstrap/72823)


On Sat, 2016-08-06 at 11:29 +0530, Prathamesh Kulkarni wrote:
> On 6 August 2016 at 11:16, Markus Trippelsdorf <
> markus@trippelsdorf.de> wrote:
> > On 2016.08.05 at 14:16 -0400, David Malcolm wrote:
> > > Successfully bootstrapped&regrtested the updated patch on x86_64
> > > -pc
> > > -linux-gnu, and successfully ran the stage 1 selftests on powerpc
> > > -ibm
> > > -aix7.1.3.0 (gcc111)
> > > 
> > > Committed to trunk as r239175; I'm attaching the final version of
> > > the
> > > patch for reference.
> > 
> > It breaks the build on ppc64le (gcc112):
> FWIW I am observing the same error on x86_64-unknown-linux-gnu:
> http://pastebin.com/63k4CRVY
> 
> Thanks,
> Prathamesh
> > 
> > /home/trippels/gcc_build_dir/./gcc/xgcc 
> > -B/home/trippels/gcc_build_dir/./gcc/ -xc -S -c /dev/null -fself
> > -test
> > cc1: internal compiler error: Segmentation fault
> > 0x1088b293 crash_signal
> >         ../../gcc/gcc/toplev.c:335
> > 0x1115c694 cpp_string_location_reader::get_next()
> >         ../../gcc/libcpp/charset.c:2143
> > 0x1115c694 _cpp_valid_ucn
> >         ../../gcc/libcpp/charset.c:1079
> > Please submit a full bug report,
> > with preprocessed source if appropriate.
> > Please include the complete backtrace with any bug report.
> > See <http://gcc.gnu.org/bugs.html> for instructions.
> > Makefile:1898: recipe for target 's-selftest' failed
> > 
> > --
> > Markus

Sorry about the breakage.  Looks like gcc_assert in libcpp/system.h can
sometimes enforce the assertion, and sometimes be a no-op, depending on
the host compiler.

I was able to reliably reproduce the crash on hacking up my
libcpp/system.h so that gcc_assert was enforced.

I've committed the attached patch to trunk as r239211.
(survives selftest with hacked-up gcc_assert; reported as fixing the
issue on IRC; survived bootstrap also).

I'll have a look at improving the libcpp assert situation on Monday.

Sorry again about the breakage

Dave
From 0a35b0da798bb2dd4e5af23505075b74558fe956 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Sat, 6 Aug 2016 14:05:24 -0400
Subject: [PATCH] Fix crash in selftest::test_lexer_string_locations_ucn4 (PR
 bootstrap/72823)

libcpp/ChangeLog:
	PR bootstrap/72823
	* charset.c (_cpp_valid_ucn): Replace overzealous assert with one
	that allows for char_range to be non-NULL when loc_reader is NULL.
---
 libcpp/charset.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/libcpp/charset.c b/libcpp/charset.c
index 3739d6c..6a92ade 100644
--- a/libcpp/charset.c
+++ b/libcpp/charset.c
@@ -1027,7 +1027,7 @@ ucn_valid_in_identifier (cpp_reader *pfile, cppchar_t c,
    IDENTIFIER_POS is 0 when not in an identifier, 1 for the start of
    an identifier, or 2 otherwise.
 
-   If CHAR_RANGE and LOC_READER are non-NULL, then position information is
+   If LOC_READER is non-NULL, then position information is
    read from *LOC_READER and CHAR_RANGE->m_finish is updated accordingly.  */
 
 bool
@@ -1042,10 +1042,6 @@ _cpp_valid_ucn (cpp_reader *pfile, const uchar **pstr,
   const uchar *str = *pstr;
   const uchar *base = str - 2;
 
-  /* char_range and loc_reader must either be both NULL, or both be
-     non-NULL.  */
-  gcc_assert ((char_range != NULL) == (loc_reader != NULL));
-
   if (!CPP_OPTION (pfile, cplusplus) && !CPP_OPTION (pfile, c99))
     cpp_error (pfile, CPP_DL_WARNING,
 	       "universal character names are only valid in C++ and C99");
@@ -1076,7 +1072,10 @@ _cpp_valid_ucn (cpp_reader *pfile, const uchar **pstr,
 	break;
       str++;
       if (loc_reader)
-	char_range->m_finish = loc_reader->get_next ().m_finish;
+	{
+	  gcc_assert (char_range);
+	  char_range->m_finish = loc_reader->get_next ().m_finish;
+	}
       result = (result << 4) + hex_value (c);
     }
   while (--length && str < limit);
-- 
1.8.5.3


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