Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Clang stack overflow while reporting infinite-template-recursion error #15101

Open Quuxplusone opened 11 years ago

Quuxplusone commented 11 years ago
Bugzilla Link PR15101
Status NEW
Importance P enhancement
Reported by Isaac Dupree (antispam@idupree.com)
Reported on 2013-01-28 22:37:05 -0800
Last modified on 2013-03-13 22:45:04 -0700
Version 3.2
Hardware PC Linux
CC dgregor@apple.com, llvm-bugs@lists.llvm.org, rafael@espindo.la
Fixed by commit(s)
Attachments units_tests-AHlBLW.sh (787 bytes, application/x-sh)
units_tests-AHlBLW.cpp.xz (583280 bytes, application/x-xz)
Blocks
Blocked by
See also
I was coding some C++ and accidentally wrote a template that made infinite
template recursion.  While attempting to report the error, Clang stack-
overflowed and told me to report the bug.

Probably-related comment I found in bugzilla:
http://llvm.org/bugs/show_bug.cgi?id=13263#c5 point (2).

Output from Clang:

In file included from
/Users/me/programming/lasercake/Lasercake/tests/units_tests.cpp:24:
/Users/me/programming/lasercake/Lasercake/tests/../units.hpp:300:22: fatal
error: recursive
      template instantiation exceeded maximum depth of 512
  friend inline auto operator*(unit a, AnyInt factor)
                     ^
/Users/me/programming/lasercake/Lasercake/tests/../units.hpp:300:22: note:
while substituting
      deduced template arguments into function template 'operator*' [with AnyInt = unit<int,
      units<boost::ratio<1, 1>, 0, 1, 0, 0, 0, 0> >]
  friend inline auto operator*(unit a, AnyInt factor)
                     ^
/Users/me/programming/lasercake/Lasercake/tests/../units.hpp:300:22: note:
while substituting
      deduced template arguments into function template 'operator*' [with AnyInt = unit<int,
      units<boost::ratio<1, 1>, 0, 1, 0, 0, 0, 0> >]
  friend inline auto operator*(unit a, AnyInt factor)
                     ^
/Users/me/programming/lasercake/Lasercake/tests/../units.hpp:300:22: note:
while substituting
      deduced template arguments into function template 'operator*' [with AnyInt = unit<int,
      units<boost::ratio<1, 1>, 0, 1, 0, 0, 0, 0> >]
  friend inline auto operator*(unit a, AnyInt factor)
                     ^
/Users/me/programming/lasercake/Lasercake/tests/../units.hpp:300:22: note:
while substituting
      deduced template arguments into function template 'operator*' [with AnyInt = unit<int,
      units<boost::ratio<1, 1>, 0, 1, 0, 0, 0, 0> >]
  friend inline auto operator*(unit a, AnyInt factor)
                     ^
/Users/me/programming/lasercake/Lasercake/tests/../units.hpp:300:22: note:
while substituting
      deduced template arguments into function template 'operator*' [with AnyInt = unit<int,
      units<boost::ratio<1, 1>, 0, 1, 0, 0, 0, 0> >]
  friend inline auto operator*(unit a, AnyInt factor)
                     ^
/Users/me/programming/lasercake/Lasercake/tests/../units.hpp:300:22: note:
(skipping 503
      contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all)
/Users/me/programming/lasercake/Lasercake/tests/../units.hpp:300:22: note:
while substituting
      deduced template arguments into function template 'operator*' [with AnyInt = unit<int,
      units<boost::ratio<1, 1>, 0, 1, 0, 0, 0, 0> >]
  friend inline auto operator*(unit a, AnyInt factor)
                     ^
/Users/me/programming/lasercake/Lasercake/tests/../units.hpp:300:22: note:
while substituting
      deduced template arguments into function template 'operator*' [with AnyInt = unit<int,
      units<boost::ratio<1, 1>, 0, 1, 0, 0, 0, 0> >]
  friend inline auto operator*(unit a, AnyInt factor)
                     ^
/Users/me/programming/lasercake/Lasercake/tests/../units.hpp:300:22: note:
while substituting
      deduced template arguments into function template 'operator*' [with AnyInt = unit<int,
      units<boost::ratio<1, 1>, 0, 1, 0, 0, 0, 0> >]
  friend inline auto operator*(unit a, AnyInt factor)
                     ^
/Users/me/programming/lasercake/Lasercake/tests/../units.hpp:300:22: note:
while substituting
      deduced template arguments into function template 'operator*' [with AnyInt = unit<int,
      units<boost::ratio<1, 1>, 0, 1, 0, 0, 0, 0> >]
  friend inline auto operator*(unit a, AnyInt factor)
                     ^
/Users/me/programming/lasercake/Lasercake/tests/../units.hpp:300:22: note:
while substituting
      deduced template arguments into function template 'operator*' [with AnyInt = unit<int,
      units<boost::ratio<1, 1>, 0, 1, 0, 0, 0, 0> >]
  friend inline auto operator*(unit a, AnyInt factor)
                     ^
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.2 (tags/RELEASE_32/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix

Backtrace I got from gdb'ing the test .sh:

Program received signal SIGSEGV, Segmentation fault.
0x0000000000fabebb in ?? ()
(gdb) bt
#0  0x0000000000fabebb in ?? ()
#1  0x0000000000faad53 in ?? ()
#2  0x0000000000faafea in clang::QualType::getAsStringInternal(clang::Type
const*, clang::Qualifiers, std::string&, clang::PrintingPolicy const&) ()
#3  0x0000000000f9ad51 in clang::TemplateArgument::print(clang::PrintingPolicy
const&, llvm::raw_ostream&) const ()
#4  0x0000000000fa7333 in
clang::TemplateSpecializationType::PrintTemplateArgumentList(llvm::raw_ostream&,
clang::TemplateArgument const*, unsigned int, clang::PrintingPolicy const&,
bool) ()
#5  0x0000000000fa7caf in ?? ()
#6  0x0000000000fabed9 in ?? ()
#7  0x0000000000faad53 in ?? ()
#8  0x0000000000faafea in clang::QualType::getAsStringInternal(clang::Type
const*, clang::Qualifiers, std::string&, clang::PrintingPolicy const&) ()
#9  0x0000000000f9ad51 in clang::TemplateArgument::print(clang::PrintingPolicy
const&, llvm::raw_ostream&) const ()
#10 0x0000000000fa7333 in
clang::TemplateSpecializationType::PrintTemplateArgumentList(llvm::raw_ostream&,
clang::TemplateArgument const*, unsigned int, clang::PrintingPolicy const&,
bool) ()
#11 0x0000000000fa7caf in ?? ()
#12 0x0000000000fabed9 in ?? ()
#13 0x0000000000faad53 in ?? ()
#14 0x0000000000faafea in clang::QualType::getAsStringInternal(clang::Type
const*, clang::Qua---Type <return> to continue, or q <return> to quit---
lifiers, std::string&, clang::PrintingPolicy const&) ()
#15 0x0000000000f9ad51 in clang::TemplateArgument::print(clang::PrintingPolicy
const&, llvm::raw_ostream&) const ()
#16 0x0000000000fa7333 in
clang::TemplateSpecializationType::PrintTemplateArgumentList(llvm::raw_ostream&,
clang::TemplateArgument const*, unsigned int, clang::PrintingPolicy const&,
bool) ()
#17 0x0000000000fa7caf in ?? ()
#18 0x0000000000fabed9 in ?? ()
#19 0x0000000000faad53 in ?? ()
#20 0x0000000000faafea in clang::QualType::getAsStringInternal(clang::Type
const*, clang::Qualifiers, std::string&, clang::PrintingPolicy const&) ()
#21 0x0000000000f9ad51 in clang::TemplateArgument::print(clang::PrintingPolicy
const&, llvm::raw_ostream&) const ()
#22 0x0000000000fa7333 in
clang::TemplateSpecializationType::PrintTemplateArgumentList(llvm::raw_ostream&,
clang::TemplateArgument const*, unsigned int, clang::PrintingPolicy const&,
bool) ()
#23 0x0000000000fa7caf in ?? ()
#24 0x0000000000fabed9 in ?? ()
#25 0x0000000000faad53 in ?? ()
#26 0x0000000000faafea in clang::QualType::getAsStringInternal(clang::Type
const*, clang::Qualifiers, std::string&, clang::PrintingPolicy const&) ()
#27 0x0000000000f9ad51 in clang::TemplateArgument::print(clang::PrintingPolicy
const&, llvm::raw_ostream&) const ()
---Type <return> to continue, or q <return> to quit---
#28 0x0000000000fa7333 in
clang::TemplateSpecializationType::PrintTemplateArgumentList(llvm::raw_ostream&,
clang::TemplateArgument const*, unsigned int, clang::PrintingPolicy const&,
bool) ()
#29 0x0000000000fa7caf in ?? ()
#30 0x0000000000fabed9 in ?? ()
#31 0x0000000000faad53 in ?? ()
#32 0x0000000000faafea in clang::QualType::getAsStringInternal(clang::Type
const*, clang::Qualifiers, std::string&, clang::PrintingPolicy const&) ()
#33 0x0000000000f9ad51 in clang::TemplateArgument::print(clang::PrintingPolicy
const&, llvm::raw_ostream&) const ()
[...continues in this vein for a long time]
Quuxplusone commented 11 years ago

Attached units_tests-AHlBLW.sh (787 bytes, application/x-sh): run script

Quuxplusone commented 11 years ago

Attached units_tests-AHlBLW.cpp.xz (583280 bytes, application/x-xz): preprocessed source (compressed to fit within upload limit)