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

            Bug ID: 60745
           Summary: Many ICEs running libstdc++ testsuite with ubsan,
                    maybe due to PCH
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: sanitizer
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
                CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
                    jakub at gcc dot gnu.org, kcc at gcc dot gnu.org,
                    mpolacek at gcc dot gnu.org

In the $target/libstdc++-v3 build dir:

LD_LIBRARY_PATH=$PWD/../libsanitizer/ubsan/.libs \
  make check \
  RUNTESTFLAGS="conformance.exp=20_util/allocator/33807.cc \
  --target_board=unix/-fsanitize=undefined"

that test (and many others) FAILs with an ICE:

In file included from
/home/jwakely/build/x86_64-unknown-linux-gnu/libstdc++-v3/include/list:64:0,
                 from
/home/jwakely/src/gcc/libstdc++-v3/include/precompiled/stdc++.h:78:
/home/jwakely/build/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/list.tcc:
In instantiation of 'std::list<_Tp, _Alloc>::iterator std::list<_Tp,
_Alloc>::erase(std::list<_Tp, _Alloc>::iterator) [with _Tp = foo; _Alloc =
std::allocator<foo>; std::list<_Tp, _Alloc>::iterator =
std::_List_iterator<foo>]':
/home/jwakely/build/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/stl_list.h:1270:27:
  required from 'std::list<_Tp, _Alloc>::iterator std::list<_Tp,
_Alloc>::erase(std::list<_Tp, _Alloc>::iterator, std::list<_Tp,
_Alloc>::iterator) [with _Tp = foo; _Alloc = std::allocator<foo>;
std::list<_Tp, _Alloc>::iterator = std::_List_iterator<foo>]'
/home/jwakely/build/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/list.tcc:239:29:
  required from 'std::list<_Tp, _Alloc>& std::list<_Tp,
_Alloc>::operator=(const std::list<_Tp, _Alloc>&) [with _Tp = foo; _Alloc =
std::allocator<foo>]'
/home/jwakely/src/gcc/libstdc++-v3/testsuite/20_util/allocator/33807.cc:31:6:  
required from here
/home/jwakely/build/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/list.tcc:156:5:
internal compiler error: Segmentation fault
     }
     ^
0xb62985 crash_signal
        /home/jwakely/src/gcc/gcc/toplev.c:337
0x7d7b93 contains_struct_check
        /home/jwakely/src/gcc/gcc/tree.h:2826
0x7d7b93 build_call_expr_loc_array(unsigned int, tree_node*, int, tree_node**)
        /home/jwakely/src/gcc/gcc/builtins.c:11263
0x7d9796 build_call_expr_loc(unsigned int, tree_node*, int, ...)
        /home/jwakely/src/gcc/gcc/builtins.c:11296
0x7b1416 ubsan_instrument_return(unsigned int)
        /home/jwakely/src/gcc/gcc/c-family/c-ubsan.c:191
0x730376 cp_ubsan_maybe_instrument_return
        /home/jwakely/src/gcc/gcc/cp/cp-gimplify.c:1256
0x730376 cp_genericize(tree_node*)
        /home/jwakely/src/gcc/gcc/cp/cp-gimplify.c:1324
0x60f790 cp_write_global_declarations()
        /home/jwakely/src/gcc/gcc/cp/decl2.c:4312
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.


The source of that test is:

// { dg-do compile }

// Copyright (C) 2007-2014 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3.  If not see
// <http://www.gnu.org/licenses/>.

#include <list>

// libstdc++/33807
template <class T>
bool operator != (const T& x, const T& y) { return !(x == y); }

struct foo { };

void fnx()
{
  std::list<foo> l1, l2;
  l1 = l2;
}


but compiling the same file with an installed compiler, or compiling
preprocessed source, doesn't fail.

Running the command used by the testsuite doesn't crash if I remove the
"-include stdc++.h" so it may be related to PCH.

GDB shows:

Program received signal SIGSEGV, Segmentation fault.
build_call_expr_loc_array (loc=11088345, fndecl=0x0, n=1,
argarray=0x7fffffffd2a0) at /home/jwakely/src/gcc/gcc/gcc/builtins.c:11263
11263    tree fntype = TREE_TYPE (fndecl);
(gdb) p fndecl
$1 = (tree_node *) 0x0
(gdb) bt
#0  build_call_expr_loc_array (loc=11088345, fndecl=0x0, n=1,
argarray=0x7fffffffd2a0) at /home/jwakely/src/gcc/gcc/gcc/builtins.c:11263
#1  0x00000000007ebdce in build_call_expr_loc (loc=<optimized out>,
fndecl=fndecl@entry=0x0, n=n@entry=1) at
/home/jwakely/src/gcc/gcc/gcc/builtins.c:11296
#2  0x00000000007bf747 in ubsan_instrument_return (loc=11088345) at
/home/jwakely/src/gcc/gcc/gcc/c-family/c-ubsan.c:191
#3  0x0000000000743f25 in cp_ubsan_maybe_instrument_return
(fndecl=0x7ffff1a0f500) at /home/jwakely/src/gcc/gcc/gcc/cp/cp-gimplify.c:1256
#4  cp_genericize (fndecl=fndecl@entry=0x7ffff1a0f500) at
/home/jwakely/src/gcc/gcc/gcc/cp/cp-gimplify.c:1324
#5  0x0000000000578a90 in finish_function (flags=flags@entry=0) at
/home/jwakely/src/gcc/gcc/gcc/cp/decl.c:14023
#6  0x00000000005b1ba2 in instantiate_decl (d=<optimized out>,
d@entry=0x7ffff1a0f500, defer_ok=<optimized out>, defer_ok@entry=0,
expl_inst_class_mem_p=expl_inst_class_mem_p@entry=false) at
/home/jwakely/src/gcc/gcc/gcc/cp/pt.c:19923
#7  0x00000000005f1cf7 in instantiate_pending_templates
(retries=retries@entry=0) at /home/jwakely/src/gcc/gcc/gcc/cp/pt.c:20017
#8  0x000000000062dbf7 in cp_write_global_declarations () at
/home/jwakely/src/gcc/gcc/gcc/cp/decl2.c:4312
#9  0x0000000000b581f5 in compile_file () at
/home/jwakely/src/gcc/gcc/gcc/toplev.c:562
#10 0x0000000000b5a0b8 in do_compile () at
/home/jwakely/src/gcc/gcc/gcc/toplev.c:1914
#11 toplev_main (argc=32, argv=0x7fffffffd708) at
/home/jwakely/src/gcc/gcc/gcc/toplev.c:1990
#12 0x0000003eba021d65 in __libc_start_main (main=0x53fc50 <main(int, char**)>,
argc=32, argv=0x7fffffffd708, init=<optimized out>, fini=<optimized out>,
rtld_fini=<optimized out>, stack_end=0x7fffffffd6f8) at libc-start.c:285
#13 0x000000000053fcd1 in _start ()

Reply via email to