Bug 64984 - [5 Regression] ICE in check_noexcept_t with ubsan
Summary: [5 Regression] ICE in check_noexcept_t with ubsan
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: sanitizer (show other bugs)
Version: 5.0
: P3 normal
Target Milestone: 5.0
Assignee: Jakub Jelinek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-09 15:49 UTC by Lars Gullik Bjønnes
Modified: 2015-02-12 15:40 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2015-02-09 00:00:00


Attachments
gcc5-pr64984.patch (914 bytes, patch)
2015-02-10 10:04 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Lars Gullik Bjønnes 2015-02-09 15:49:12 UTC
With this test program I get an ICE.

----------
#include <map>

class Type
{
public:
    Type();
    virtual ~Type();

    bool operator<(const Type &) const;
};

int main()
{
    std::map<Type, int> map;
    map[Type()] = 0;
}
------------

g++ --version
g++ (GCC) 5.0.0 20150203 (experimental)

g++ -fsanitize=undefined -std=gnu++11 -c test.cpp

In file included from /opt/gcc/gcc-trunk/include/c++/5.0.0/bits/move.h:57:0,
                 from /opt/gcc/gcc-trunk/include/c++/5.0.0/bits/stl_pair.h:59,
                 from /opt/gcc/gcc-trunk/include/c++/5.0.0/bits/stl_algobase.h:64,
                 from /opt/gcc/gcc-trunk/include/c++/5.0.0/bits/stl_tree.h:63,
                 from /opt/gcc/gcc-trunk/include/c++/5.0.0/map:60,
                 from test.cpp:1:
/opt/gcc/gcc-trunk/include/c++/5.0.0/type_traits: In instantiation of ‘struct std::__is_nt_constructible_impl<Type&&, Type&&>’:
/opt/gcc/gcc-trunk/include/c++/5.0.0/type_traits:137:12:   required from ‘struct std::__and_<std::is_constructible<Type&&, Type&&>, std::__is_nt_constructible_impl<Type&&, Type&&> >’
/opt/gcc/gcc-trunk/include/c++/5.0.0/type_traits:1174:12:   required from ‘struct std::is_nothrow_constructible<Type&&, Type&&>’
/opt/gcc/gcc-trunk/include/c++/5.0.0/type_traits:1205:12:   required from ‘struct std::__is_nothrow_move_constructible_impl<Type&&, true>’
/opt/gcc/gcc-trunk/include/c++/5.0.0/type_traits:1211:12:   required from ‘struct std::is_nothrow_move_constructible<Type&&>’
/opt/gcc/gcc-trunk/include/c++/5.0.0/tuple:367:7:   required from ‘constexpr std::_Tuple_impl<_Idx, _Head>::_Tuple_impl(std::_Tuple_impl<_Idx, _Head>&&) [with long unsigned int _Idx = 0ul; _Head = Type&&]’
/opt/gcc/gcc-trunk/include/c++/5.0.0/tuple:976:70:   required from ‘std::tuple<_Elements&& ...> std::forward_as_tuple(_Elements&& ...) [with _Elements = {Type}]’
/opt/gcc/gcc-trunk/include/c++/5.0.0/bits/stl_map.h:500:27:   required from ‘std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = Type; _Tp = int; _Compare = std::less<Type>; _Alloc = std::allocator<std::pair<const Type, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = Type]’
test.cpp:15:15:   required from here
/opt/gcc/gcc-trunk/include/c++/5.0.0/type_traits:1162:12: internal compiler error: Segmentation fault
     struct __is_nt_constructible_impl<_Tp, _Arg>
            ^
0xa89c7f crash_signal
        ../../gcc/gcc/toplev.c:383
0x69ea1b check_noexcept_r
        ../../gcc/gcc/cp/except.c:1162
0xc6b254 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, default_hashset_traits>*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, default_hashset_traits>*))
        ../../gcc/gcc/tree.c:11086
0xc6b438 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, default_hashset_traits>*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, default_hashset_traits>*))
        ../../gcc/gcc/tree.c:11390
0xc6ca18 walk_tree_without_duplicates_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, default_hashset_traits>*))
        ../../gcc/gcc/tree.c:11416
0x69e7cf expr_noexcept_p(tree_node*, int)
        ../../gcc/gcc/cp/except.c:1255
0x69e922 finish_noexcept_expr(tree_node*, int)
        ../../gcc/gcc/cp/except.c:1240
0x61e2ee tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool)
        ../../gcc/gcc/cp/pt.c:14880
0x61b6ab tsubst_expr
        ../../gcc/gcc/cp/pt.c:14383
0x61c63c tsubst_template_arg
        ../../gcc/gcc/cp/pt.c:9692
0x626839 tsubst_template_args
        ../../gcc/gcc/cp/pt.c:10242
0x623544 tsubst_aggr_type
        ../../gcc/gcc/cp/pt.c:10439
0x617771 tsubst(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/gcc/cp/pt.c:11894
0x631c69 instantiate_class_template_1
        ../../gcc/gcc/cp/pt.c:9260
0x631c69 instantiate_class_template(tree_node*)
        ../../gcc/gcc/cp/pt.c:9673
0x68aa5d complete_type(tree_node*)
        ../../gcc/gcc/cp/typeck.c:146
0x68aaff complete_type_or_maybe_complain(tree_node*, tree_node*, int)
        ../../gcc/gcc/cp/typeck.c:158
0x608d09 xref_basetypes(tree_node*, tree_node*)
        ../../gcc/gcc/cp/decl.c:12493
0x63116e instantiate_class_template_1
        ../../gcc/gcc/cp/pt.c:9279
0x63116e instantiate_class_template(tree_node*)
        ../../gcc/gcc/cp/pt.c:9673
Comment 1 Marek Polacek 2015-02-09 15:56:57 UTC
Confirmed.  Seems to be a bug in the vptr checking; -std=gnu++11 -fsanitize=vptr ICEs, -std=gnu++11 -fsanitize=undefined -fno-sanitize=vptr compiles ok.
Comment 2 Jakub Jelinek 2015-02-09 16:22:48 UTC
I'll have a look tomorrow.
Comment 3 Jakub Jelinek 2015-02-10 10:04:38 UTC
Created attachment 34710 [details]
gcc5-pr64984.patch

Untested fix.
Comment 4 Lars Gullik Bjønnes 2015-02-10 12:28:01 UTC
(In reply to Jakub Jelinek from comment #3)
> Created attachment 34710 [details]
> gcc5-pr64984.patch
> 
> Untested fix.

This seems to fix ICE, but I have at least one more that needs tracking down,
also related to -fsanitize=undefined, but not to -fsanitize=vptr.
(and a hang with -fsanitize=address and heap-use-after-free reporting.)

I'll create separate bugs for those.
Comment 5 Jakub Jelinek 2015-02-12 15:39:04 UTC
Author: jakub
Date: Thu Feb 12 15:38:33 2015
New Revision: 220649

URL: https://gcc.gnu.org/viewcvs?rev=220649&root=gcc&view=rev
Log:
	PR sanitizer/64984
	* except.c (check_noexcept_r): Return NULL for internal
	calls.

	* g++.dg/ubsan/pr64984.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/ubsan/pr64984.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/except.c
    trunk/gcc/testsuite/ChangeLog
Comment 6 Jakub Jelinek 2015-02-12 15:40:31 UTC
Fixed.