Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Assertion failure caused by dependent types in codegen leaking through friend function templates #26511

Open Quuxplusone opened 8 years ago

Quuxplusone commented 8 years ago
Bugzilla Link PR26512
Status REOPENED
Importance P normal
Reported by mattreecebentley@gmail.com (mattreecebentley@gmail.com)
Reported on 2016-02-06 21:29:58 -0800
Last modified on 2017-07-23 04:17:09 -0700
Version 3.7
Hardware PC Windows NT
CC dgregor@apple.com, llvm-bugs@lists.llvm.org, rnk@google.com, sepavloff@gmail.com
Fixed by commit(s)
Attachments plf_test_suite-30f80b.zip (346670 bytes, application/zip)
Blocks
Blocked by
See also
Total crash readout follows:
"
C:\Windows\system32\cmd.exe /C D:/programming/libraries/mingw/bin/mingw32-
make.exe -j2 SHELL=cmd.exe -e -f  "plf_colonies_x64.mk"  MakeIntermediateDirs
&& D:/programming/libraries/mingw/bin/mingw32-make.exe -j2 SHELL=cmd.exe -e -f
"plf_colonies_x64.mk"  all
----------Building project:[ plf_colonies_x64 - Debug ]----------
D:/programming/libraries/llvm/bin/clang++.exe  -c
"D:/programming/projects/plf_colony/code/plf_test_suite.cpp" -g -Wall -O0   -o
./Debug/code_plf_test_suite.cpp.o -
ID:/programming/libraries/mingw/lib/gcc/x86_64-w64-mingw32/5.1.0/include/c++ -
ID:/programming/libraries/mingw/lib/gcc/x86_64-w64-
mingw32/5.1.0/include/c++/x86_64-w64-mingw32 -
ID:/programming/libraries/mingw/lib/gcc/x86_64-w64-
mingw32/5.1.0/include/c++/backward -
ID:/programming/libraries/mingw/lib/gcc/x86_64-w64-mingw32/5.1.0/include -
ID:/programming/libraries/mingw/include -
ID:/programming/libraries/mingw/lib/gcc/x86_64-w64-mingw32/5.1.0/include-fixed -
ID:/programming/libraries/mingw/x86_64-w64-mingw32/include  -I. -
Id:/programming/libraries/SDLx64/include/SDL2 -Id:/programming/mingw/include
Assertion failed: !T->isDependentType() && "should not see dependent types
here", file
D:\src\llvm_release_build_3.7.1\llvm\tools\clang\include\clang/AST/TypeNodes.def,
line 98
0x0000000140D41735 (0x0000000000000016 0x0000000114474BF8 0x0000000000000000
0x00000000776F815A)
0x0000000141F5428D (0x0000000100000001 0x0000000100000000 0x0000000142A70770
0x000000000000008C)
0x0000000141F4A70C (0x0000000142CAB9A0 0x0000000142A70770 0x0000000142A70820
0x0000000142A70770)
0x0000000141F49663 (0x0000000000000000 0x0000000140A7E5A5 0x000000000377CF80
0x0000000000000008)
0x0000000141E1F5AC (0x000000000012B3E0 0x0000000000B9BF70 0x0000000000000008
0x0000000000000000)
0x0000000141E1F261 (0x0000000003430850 0x000000000012AFD0 0x00000000031CB4E0
0x00000000031CB4E0)
0x0000000141E1BC3F (0x00000000031CB4E0 0x00000000031CB4E0 0x0000000000000008
0x00000000031CB4E0)
0x0000000141E0F954 (0x0000000000000008 0x0000000000B9C088 0x00000000034B3C20
0x0000000140A96800)
0x0000000140F2A2BC (0x00000000031CB4E0 0x0000000000190B01 0x00000000034B3C20
0x0000000140A7E5A5)
0x0000000140F2D4E0 (0x00000000034B3DA8 0x00000000034B3DA0 0x0000000000190B20
0x00000000001E1790)
0x0000000140FAEE2D (0x00000000001E1790 0x0000000000B9CFB0 0x0000000000B9C190
0x0000000000000000)
0x0000000140FB0EEF (0x0000000002D7C698 0x00000005000007FC 0x00000000034B3DA0
0x0000000002D7C698)
0x0000000140FB1118 (0x0000000000190B20 0x00000000034B4570 0x0000000000B9CFB0
0x0000000000000000)
0x0000000140FAE5FB (0x00000000001E1788 0x0000000000B9C2D9 0x0000000000B9CFB0
0x0000000140A969C6)
0x0000000140FAE46D (0x0000000000B9C3C0 0x0000000140FB4257 0x0000000003759B20
0x00000001409D4AFE)
0x0000000140FB0ED4 (0x0000000003759B20 0x0000000140AC7521 0x00000000034B4558
0x0000000000B9C448)
0x0000000140FB1118 (0x0000000003759BE0 0x0000000000000000 0x0000000000000000
0x0000000000000000)
0x0000000140FB0193 (0x00000000001E1702 0x0000000000B9CFB0 0x0000000000B9CFB0
0x0000000002D7C698)
0x0000000140FB1256 (0x0000000000190B20 0x00000000034B5238 0x0000000000B9CFB0
0x0000000000000001)
0x0000000140FAE5FB (0x00000000001E16C7 0x0000000000B9C699 0x0000000000B9CFB0
0x0000000140A969C6)
0x0000000140FAE46D (0x0000000000B9C780 0x0000000140FB4257 0x0000000003759A00
0x00000001409D4AFE)
0x0000000140FB0ED4 (0x0000000003759A00 0x0000000140AC7521 0x00000000034B5218
0x0000000000B9C7D8)
0x0000000140FB1118 (0x0000000003759A60 0x0000000000000000 0x0000000000000000
0x0000000000000000)
0x0000000140FB0193 (0x00000000001E168E 0x0000000000B9CFB0 0x0000000000B9CFB0
0x0000000002D7C698)
0x0000000140FB1256 (0x0000000000190B20 0x00000000034B6458 0x0000000000B9CFB0
0x0000000000000000)
0x0000000140FAE5FB (0x00000000001E1608 0x0000000000B9CA59 0x0000000000B9CFB0
0x0000000140A969DC)
0x0000000140FAE46D (0x0000000000B9CB40 0x0000000140FB4257 0x00000000037598E0
0x00000001409D4AFE)
0x0000000140FB0ED4 (0x00000000037598E0 0x0000000140AC7521 0x00000000034B6440
0x0000000000B9CBC8)
0x0000000140FB1118 (0x00000000037599A0 0x0000000000000000 0x0000000000000000
0x0000000000000000)
0x0000000140FB0193 (0x00000000001E156E 0x0000000000B9CFB0 0x0000000000B9CFB0
0x00000000032D8460)
0x0000000140FB1256 (0x00000000000BB520 0x00000000034B6868 0x0000000000B9CFB0
0x0000000000000004)
0x0000000140FAE5FB (0x00000000034B6830 0x0000000000B9CEA0 0x00000000001E23BE
0x00000000032D8650)
0x0000000140F0F824 (0x00000000001E1460 0x00000000001E23BE 0x00000000001E23BE
0x00000000033CEE98)
0x0000000140F13A90 (0x000000000336CA88 0x00000000032D8650 0x00000000032D8650
0x000000000336CA88)
0x0000000140E63748 (0x0000000000000000 0x00000000032D8650 0x00000000033DACA0
0x00000000033CEE98)
0x0000000140E631E5 (0x00000000033DACA0 0x00000000032D8650 0x00000000032D8650
0x000000000018F6B0)
0x0000000140E6214B (0x00000000033DB350 0x00000000033DA910 0x0000000000000000
0x000000000018F6B0)
0x0000000140E6A4FF (0x0000000000000000 0x0000000000127E40 0x000000000012AFD0
0x0000000000187F70)
0x000000014202C7C1 (0x0000000000127E40 0x0000000000127E40 0x000000000015BBC0
0x0000000000000000)
0x00000001415F8E75 (0x0000000000000000 0x0000000000B9DD00 0x00000000000E7630
0x0000000200000001)
0x000000014111627B (0x00000000000E7630 0x0000000000000000 0x0000000000000002
0x00000000000FC7F0)
0x000000014202C30C (0x0000000000000000 0x0000000000000000 0x0000000000000001
0x0000000142CB6520)
0x0000000141116118 (0x0000000000000000 0x00000000000FC170 0x00000000000F7950
0x0000000000000000)
0x00000001410EDDE7 (0x00000001409D60A0 0x00000000000E7630 0x0000000000B9DFB9
0x00000001409D7DA0)
0x0000000141159C2B (0x00000000000FA0A0 0x00000000000FAB10 0x00000000000FABB0
0x00000000000E3F90)
0x000000013FFA2E79 (0x0000000000000068 0x0000000100000000 0x0000000142C87010
0x0000000000B9E750)
0x000000013FF9E234 (0x0000000000000068 0x00000000000F696E 0x0000000000B9E7B0
0x0000000000000000)
0x000000013FFA167D (0x0000000000000000 0x0000000000000000 0x0000000000000001
0x0000000000000000)
0x0000000141F4A234 (0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000)
0x00000000774C59DD (0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000), BaseThreadInitThunk() + 0xD bytes(s)
0x00000000776FA671 (0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000), RtlUserThreadStart() + 0x21 bytes(s)
clang++.exe: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.7.1 (tags/RELEASE_371/final)
Target: x86_64-w64-windows-gnu
Thread model: posix
clang++.exe: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and
associated run script.
clang++.exe: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang++.exe: note: diagnostic msg: v:\SYSTEM~2\plf_test_suite-30f80b.cpp
clang++.exe: note: diagnostic msg: v:\SYSTEM~2\plf_test_suite-30f80b.sh
clang++.exe: note: diagnostic msg:

********************
mingw32-make.exe: *** [Debug/code_plf_test_suite.cpp.o] Error 1
plf_colonies_x64.mk:97: recipe for target 'Debug/code_plf_test_suite.cpp.o'
failed
====0 errors, 0 warnings====
"

Requested sources attached. Unfortunately your broken bug submitter doesn't
allow more than one attachment, so here's the .sh file as text:

"# Crash reproducer for clang version 3.7.1 (tags/RELEASE_371/final)
# Driver args: "--driver-mode=g++" "-c"
"D:/programming/projects/plf_colony/code/plf_test_suite.cpp" "-g" "-Wall" "-O0"
"-o" "./Debug/code_plf_test_suite.cpp.o" "-I"
"D:/programming/libraries/mingw/lib/gcc/x86_64-w64-mingw32/5.1.0/include/c++" "-
I" "D:/programming/libraries/mingw/lib/gcc/x86_64-w64-
mingw32/5.1.0/include/c++/x86_64-w64-mingw32" "-I"
"D:/programming/libraries/mingw/lib/gcc/x86_64-w64-
mingw32/5.1.0/include/c++/backward" "-I"
"D:/programming/libraries/mingw/lib/gcc/x86_64-w64-mingw32/5.1.0/include" "-I"
"D:/programming/libraries/mingw/include" "-I"
"D:/programming/libraries/mingw/lib/gcc/x86_64-w64-mingw32/5.1.0/include-fixed"
"-I" "D:/programming/libraries/mingw/x86_64-w64-mingw32/include" "-I" "." "-I"
"d:/programming/libraries/SDLx64/include/SDL2" "-I"
"d:/programming/mingw/include"
# Original command:  "D:\\programming\\libraries\\llvm\\bin\\clang++.exe" "-
cc1" "-triple" "x86_64-w64-windows-gnu" "-emit-obj" "-mrelax-all" "-disable-
free" "-main-file-name" "plf_test_suite.cpp" "-mrelocation-model" "pic" "-pic-
level" "2" "-mthread-model" "posix" "-fmath-errno" "-masm-verbose" "-
mconstructor-aliases" "-munwind-tables" "-target-cpu" "x86-64" "-momit-leaf-
frame-pointer" "-g" "-dwarf-column-info" "-coverage-file"
"D:\\programming\\Workspaces\\plf_colony_x64\\plf_colonies\\./Debug/code_plf_test_suite.cpp.o"
"-resource-dir" "D:\\programming\\libraries\\llvm\\bin\\..\\lib\\clang\\3.7.1"
"-I" "D:/programming/libraries/mingw/lib/gcc/x86_64-w64-
mingw32/5.1.0/include/c++" "-I" "D:/programming/libraries/mingw/lib/gcc/x86_64-
w64-mingw32/5.1.0/include/c++/x86_64-w64-mingw32" "-I"
"D:/programming/libraries/mingw/lib/gcc/x86_64-w64-
mingw32/5.1.0/include/c++/backward" "-I"
"D:/programming/libraries/mingw/lib/gcc/x86_64-w64-mingw32/5.1.0/include" "-I"
"D:/programming/libraries/mingw/include" "-I"
"D:/programming/libraries/mingw/lib/gcc/x86_64-w64-mingw32/5.1.0/include-fixed"
"-I" "D:/programming/libraries/mingw/x86_64-w64-mingw32/include" "-I" "." "-I"
"d:/programming/libraries/SDLx64/include/SDL2" "-I"
"d:/programming/mingw/include" "-internal-isystem"
"D:\\programming\\libraries\\mingw\\x86_64-w64-mingw32\\include\\c++" "-
internal-isystem" "D:\\programming\\libraries\\mingw\\x86_64-w64-
mingw32\\include\\c++\\x86_64-w64-mingw32" "-internal-isystem"
"D:\\programming\\libraries\\mingw\\x86_64-w64-mingw32\\include\\c++\\backward"
"-internal-isystem" "D:\\programming\\libraries\\mingw\\x86_64-w64-
mingw32\\include\\c++\\5.1.0" "-internal-isystem"
"D:\\programming\\libraries\\mingw\\x86_64-w64-
mingw32\\include\\c++\\5.1.0\\x86_64-w64-mingw32" "-internal-isystem"
"D:\\programming\\libraries\\mingw\\x86_64-w64-
mingw32\\include\\c++\\5.1.0\\backward" "-internal-isystem"
"D:\\programming\\libraries\\mingw\\include\\c++\\5.1.0" "-internal-isystem"
"D:\\programming\\libraries\\mingw\\include\\c++\\5.1.0\\x86_64-w64-mingw32" "-
internal-isystem"
"D:\\programming\\libraries\\mingw\\include\\c++\\5.1.0\\backward" "-internal-
isystem" "D:\\programming\\libraries\\mingw\\lib\\gcc\\x86_64-w64-
mingw32\\5.1.0\\include\\c++" "-internal-isystem"
"D:\\programming\\libraries\\mingw\\lib\\gcc\\x86_64-w64-
mingw32\\5.1.0\\include\\c++\\x86_64-w64-mingw32" "-internal-isystem"
"D:\\programming\\libraries\\mingw\\lib\\gcc\\x86_64-w64-
mingw32\\5.1.0\\include\\c++\\backward" "-internal-isystem"
"D:\\programming\\libraries\\llvm\\bin\\..\\lib\\clang\\3.7.1\\include" "-
internal-isystem" "D:\\programming\\libraries\\mingw\\lib\\gcc\\x86_64-w64-
mingw32\\5.1.0\\include" "-internal-isystem"
"D:\\programming\\libraries\\mingw\\x86_64-w64-mingw32/sys-root/mingw/include"
"-internal-isystem" "D:\\programming\\libraries\\mingw\\lib\\gcc\\x86_64-w64-
mingw32\\5.1.0\\include-fixed" "-internal-isystem"
"D:\\programming\\libraries\\mingw\\x86_64-w64-mingw32\\include" "-internal-
isystem" "D:\\programming\\libraries\\mingw\\include" "-O0" "-Wall" "-
fdeprecated-macro" "-fdebug-compilation-dir"
"D:\\programming\\Workspaces\\plf_colony_x64\\plf_colonies" "-ferror-limit"
"19" "-fmessage-length" "0" "-mstackrealign" "-fno-use-cxa-atexit" "-fobjc-
runtime=gcc" "-fcxx-exceptions" "-fexceptions" "-fdiagnostics-show-option" "-o"
"./Debug/code_plf_test_suite.cpp.o" "-x" "c++"
"D:/programming/projects/plf_colony/code/plf_test_suite.cpp"
 "D:\\programming\\libraries\\llvm\\bin\\clang++.exe" "-cc1" "-triple" "x86_64-w64-windows-gnu" "-emit-obj" "-mrelax-all" "-disable-free" "-main-file-name" "plf_test_suite.cpp" "-mrelocation-model" "pic" "-pic-level" "2" "-mthread-model" "posix" "-fmath-errno" "-masm-verbose" "-mconstructor-aliases" "-munwind-tables" "-target-cpu" "x86-64" "-momit-leaf-frame-pointer" "-g" "-dwarf-column-info" "-O0" "-Wall" "-fdeprecated-macro" "-ferror-limit" "19" "-fmessage-length" "0" "-mstackrealign" "-fno-use-cxa-atexit" "-fobjc-runtime=gcc" "-fcxx-exceptions" "-fexceptions" "-fdiagnostics-show-option" "-x" "c++" "plf_test_suite-30f80b.cpp"
"
Quuxplusone commented 8 years ago

Attached plf_test_suite-30f80b.zip (346670 bytes, application/zip): compiled source and .sh, zipped

Quuxplusone commented 8 years ago

This smells like a bug in __typeof handling, based on the source. Tentatively marking as a duplicate.

_This bug has been marked as a duplicate of bug 21973_

Quuxplusone commented 8 years ago
This appears to be different. It has to do with dependent types sneaking
through to codegen via templated friend functions (ew). Here's what I got from
reduction:

struct A {
  template <class, bool> class B {
    template <class r_colony_allocator_type, bool r_is_const,
              class distance_type>
    friend void advance(B<r_colony_allocator_type, r_is_const> &,
                        distance_type);
  };
  template <class r_colony_allocator_type, bool r_is_const, class distance_type>
  friend void advance(B<r_colony_allocator_type, r_is_const> &, distance_type) {
    distance_type a;
  }
};
int main() {
  A::B<int, false> b;
  advance(b, 0);
}
Quuxplusone commented 8 years ago
(In reply to comment #3)

It's slightly more complicated than that, but you've got the basics of it:

template <element_type, element_allocator_type>
class A
{

  template <bool>
{
  class B
  {
    template <class colony_allocator_type, bool is_const, class distance_type>
    friend void advance(B<colony_allocator_type, is_const> &,        distance_type);
  };

  template <class, bool> class C {
    template <class r_colony_allocator_type, bool r_is_const, class distance_type>
    friend void advance(B<r_colony_allocator_type, r_is_const> &,
                        distance_type);
  };

  template <class colony_allocator_type, bool s_const, class distance_type>
  friend void advance(B<colony_allocator_type, is_const> &, distance_type) {
    distance_type a;
  }

  template <class r_colony_allocator_type, bool r_is_const, class distance_type>
  friend void advance(C<r_colony_allocator_type, r_is_const> &, distance_type)
  {
    distance_type a;
  }

};
int main() {
  A::B<int, false> b;
  advance(b, 0);
}
Quuxplusone commented 8 years ago

Sorry, please ignore the above. Accidentally tabbed and hit space, submitted without realising it.

Reid, ignoring the compiler crash, can you tell me a better way to structure this based on the example?

Quuxplusone commented 7 years ago

Patch https://reviews.llvm.org/D21767 fixes this problem.