<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div>Update: it also crashes on any other builtin type, including int, double and enums. After realizing that we were building LLVM in release mode, we rebuilt in in debug, and got a more useful stack trace:<br></div>
<div> </div>
<blockquote><div>UNREACHABLE executed at .../llvm-3.3/tools/clang/lib/AST/ASTContext.cpp:1380!<br></div>
<div> </div>
<div>Program received signal SIGABRT, Aborted.<br></div>
<div>0x00007ffff6af9945 in raise () from .../lib/clangLib/libc.so.6<br></div>
<div>(gdb) bt full<br></div>
<div>#0 0x00007ffff6af9945 in raise () from .../lib/clangLib/libc.so.6<br></div>
<div>No symbol table info available.<br></div>
<div>#1 0x00007ffff6afaf21 in abort () from .../lib/clangLib/libc.so.6<br></div>
<div>No symbol table info available.<br></div>
<div>#2 0x0000000002f93571 in llvm::llvm_unreachable_internal (msg=0x3836fa0 "Should not see dependent types", file=0x38365a8 ".../llvm-3.3/tools/clang/lib/AST/ASTContext.cpp", line=1380)<br></div>
<div> at .../llvm-3.3/lib/Support/ErrorHandling.cpp:98<br></div>
<div>No locals.<br></div>
<div>#3 0x0000000001d06772 in clang::ASTContext::getTypeInfoImpl (this=0x7fffffff5e80, T=0x5096460) at .../llvm-3.3/tools/clang/lib/AST/ASTContext.cpp:1380<br></div>
<div> Width = 0<br></div>
<div> Align = 8<br></div>
<div> __PRETTY_FUNCTION__ = "std::pair<long unsigned int, unsigned int> clang::ASTContext::getTypeInfoImpl(const clang::Type*) const"<br></div>
<div>#4 0x0000000001d06677 in clang::ASTContext::getTypeInfo (this=0x7fffffff5e80, T=0x5096460) at .../llvm-3.3/tools/clang/lib/AST/ASTContext.cpp:1359<br></div>
<div> it = {Ptr = 0x7fffffff6280, End = 0x7fffffff6280}<br></div>
<div> Info = {first = 5378736, second = 60216803}<br></div>
<div>#5 0x00007ffff63c5af3 in clang::ASTContext::getTypeInfo (this=0x5096460, T=...) at .../llvm-3.3/tools/clang/include/clang/AST/ASTContext.h:1541<br></div>
<div>No locals.<br></div>
<div>#6 0x00007ffff63c5b24 in clang::ASTContext::getTypeSize (this=0x5096460, T=...) at .../llvm-3.3/tools/clang/include/clang/AST/ASTContext.h:1546<br></div>
<div>No locals.<br></div>
</blockquote><div> </div>
<div>Looking at the Clang source, this is the relevant part:<br></div>
<div> </div>
<blockquote><div>std::pair<uint64_t, unsigned> ASTContext::getTypeInfoImpl(const Type *T) const {<br></div>
<div> uint64_t Width=0;<br></div>
<div> unsigned Align=8;<br></div>
<div> switch (T->getTypeClass()) {<br></div>
<div>#define TYPE(Class, Base)<br></div>
<div>#define ABSTRACT_TYPE(Class, Base)<br></div>
<div>#define NON_CANONICAL_TYPE(Class, Base)<br></div>
<div>#define DEPENDENT_TYPE(Class, Base) case Type::Class:<br></div>
<div>#include "clang/AST/TypeNodes.def"<br></div>
<div> llvm_unreachable("Should not see dependent types"); // CRASH!<br></div>
</blockquote><div> </div>
<div>However, we know that the TypeClass is Enum, and we also checked isDependentType(), and it gave us false. So why does Clang still crash on this?<br></div>
<div> </div>
<div>Thanks!<br></div>
<div> </div>
<div id="sig19426269"><div class="signature">-- <br></div>
<div class="signature"> Gábor Kozár -- ShdNx<br></div>
<div class="signature"> kozargabor@gmail.com<br></div>
<div class="signature"> </div>
</div>
<div> </div>
<div> </div>
<div>On Mon, Oct 21, 2013, at 12:58, Gabor Kozar wrote:<br></div>
<blockquote type="cite"><div>Hi,<br></div>
<div> </div>
<div>We're using Clang 3.3.<br></div>
<div>In a Static Analyzer checker, I'm trying to determine the size of a Type. I use ASTContext::getTypeSize on it, which works fine... usually. However, on a certain Suse Linux 11 environment, attempting to do so causes a segmentation fault inside Clang. Here is the relevant part of the stack trace:<br></div>
<div> </div>
<div>0 clang-3.3 0x000000000136b592 llvm::sys::PrintStackTrace(_IO_FILE*) + 34<br></div>
<div>1 clang-3.3 0x000000000136b219<br></div>
<div>2 libpthread.so.0 0x00007ff45b1e75d0<br></div>
<div>3 clang-3.3 0x0000000001e3bc4e clang::ASTContext::getTypeInfo(clang::Type const*) const + 62<br></div>
<div> </div>
<div>The Type passed to it dumps to 'unsigned int' identifier, and is actually a TypedefType, wrapping a BuiltinType representing unsigned int. In other environments, this causes no problem.<br></div>
<div> </div>
<div>We have no root access on this system, and the gcc 4.3 is preinstalled - we have, however, created a fakeroot with gcc 4.7.1 and other goodies. Unfortunately, we are unable to prevent Clang (and even gcc 4.7.1) from having gcc 4.3's headers in the include path. I do not know if this is relevant, though - after all, builtin types shouldn't really be affected by system headers, should they?<br></div>
<div> </div>
<div>So any idea what's going on?<br></div>
<div> </div>
<div>Thanks!<br></div>
<div> </div>
<div><div>-- <br></div>
<div> Gábor Kozár -- ShdNx<br></div>
<div> kozargabor@gmail.com<br></div>
<div> </div>
</div>
</blockquote></body>
</html>