[LLVMbugs] [Bug 15101] New: Clang stack overflow while reporting infinite-template-recursion error

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jan 28 20:37:05 PST 2013


http://llvm.org/bugs/show_bug.cgi?id=15101

             Bug #: 15101
           Summary: Clang stack overflow while reporting
                    infinite-template-recursion error
           Product: clang
           Version: 3.2
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: antispam at idupree.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


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]

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list