[cfe-dev] Error during parsing

Petr Šilhavík silhape2 at fel.cvut.cz
Fri Mar 25 11:25:12 PDT 2011


Dear Clang developers,

I am developing a tool for visualizing state machines (library 
BOOST/Statechart) using LLVM and Clang release 2.8. I have no problem 
with compilation.

But when I try to use the program it returns SIGSEGV during parsing one 
of the header files of stdlib (file c++locale.h).

Stack dump:

0.    /usr/include/c++/4.4/i486-linux-gnu/bits/c++locale.h:85:5: current
parser token '__builtin_va_start'

1.    /usr/include/c++/4.4/i486-linux-gnu/bits/c++locale.h:56:1
<Spelling=/usr/include/c++/4.4/i486-linux-gnu/bits/c++config.h:114:38>:
parsing namespace 'std'

2.    /usr/include/c++/4.4/i486-linux-gnu/bits/c++locale.h:69:3: parsing
function body '__convert_from_v'

3.    /usr/include/c++/4.4/i486-linux-gnu/bits/c++locale.h:69:3: in
compound statement ('{}')

Segmentation fault (SIGSEGV)



When I use debugger I found out that there is a problem with function: 
clang::ASTContext::getTypedefType. This function has as parameter NULL 
pointer. This should be the reason why it crashes. The backtrace output 
of debugger is:

#0  0x00000000007593af in clang::ASTContext::getTypedefType (this=0x7fffffffc8b0, Decl=0x0, Canonical=...)
     at /home/sojka/boost-statechart-viewer/clang/lib/AST/ASTContext.cpp:1806
#1  0x00000000005916d5 in clang::Sema::InitBuiltinVaListType (this=0x7fffffffbd00) at /home/sojka/boost-statechart-viewer/clang/lib/Sema/SemaDecl.cpp:780
#2  0x0000000000591770 in clang::Sema::LazilyCreateBuiltin (this=0x7fffffffbd00, II=0xca4a08, bid=182, S=0xcc1030, ForRedeclaration=false, Loc=...)
     at /home/sojka/boost-statechart-viewer/clang/lib/Sema/SemaDecl.cpp:793
#3  0x0000000000662a7d in LookupBuiltin (S=..., R=...) at /home/sojka/boost-statechart-viewer/clang/lib/Sema/SemaLookup.cpp:485
#4  0x000000000066307f in LookupDirect (S=..., R=..., DC=0xcbac90) at /home/sojka/boost-statechart-viewer/clang/lib/Sema/SemaLookup.cpp:617
#5  0x0000000000663482 in CppNamespaceLookup (S=..., R=..., Context=..., NS=0xcbac90, UDirs=...) at /home/sojka/boost-statechart-viewer/clang/lib/Sema/SemaLookup.cpp:700
#6  0x0000000000664067 in clang::Sema::CppLookupName (this=0x7fffffffbd00, R=..., S=0xcc1030) at /home/sojka/boost-statechart-viewer/clang/lib/Sema/SemaLookup.cpp:984
#7  0x00000000006644cb in clang::Sema::LookupName (this=0x7fffffffbd00, R=..., S=0xcebc20, AllowBuiltinCreation=false)
     at /home/sojka/boost-statechart-viewer/clang/lib/Sema/SemaLookup.cpp:1106
#8  0x000000000058f302 in clang::Sema::getTypeName (this=0x7fffffffbd00, II=..., NameLoc=..., S=0xcebc20, SS=0x7fffffffa210, isClassName=false, ObjectTypePtr=...)
     at /home/sojka/boost-statechart-viewer/clang/lib/Sema/SemaDecl.cpp:126
#9  0x00000000004372b7 in clang::Parser::TryAnnotateTypeOrScopeToken (this=0x7fffffffba70, EnteringContext=false)
     at /home/sojka/boost-statechart-viewer/clang/lib/Parse/Parser.cpp:997
#10 0x00000000004323e9 in clang::Parser::isCXXDeclarationSpecifier (this=0x7fffffffba70) at /home/sojka/boost-statechart-viewer/clang/lib/Parse/ParseTentative.cpp:684
#11 0x0000000000431622 in clang::Parser::isCXXSimpleDeclaration (this=0x7fffffffba70) at /home/sojka/boost-statechart-viewer/clang/lib/Parse/ParseTentative.cpp:102
#12 0x00000000004315fd in clang::Parser::isCXXDeclarationStatement (this=0x7fffffffba70) at /home/sojka/boost-statechart-viewer/clang/lib/Parse/ParseTentative.cpp:64
#13 0x0000000000431280 in clang::Parser::isDeclarationStatement (this=0x7fffffffba70)
     at/home/sojka/boost-statechart-viewer/clang/lib/Parse/../../include/clang/Parse/Parser.h:1239
#14 0x000000000042c12e in clang::Parser::ParseStatementOrDeclaration (this=0x7fffffffba70, OnlyStatement=false)
     at /home/sojka/boost-statechart-viewer/clang/lib/Parse/ParseStmt.cpp:114
#15 0x000000000042d15e in clang::Parser::ParseCompoundStatementBody (this=0x7fffffffba70, isStmtExpr=false)
     at /home/sojka/boost-statechart-viewer/clang/lib/Parse/ParseStmt.cpp:474
#16 0x0000000000430858 in clang::Parser::ParseFunctionStatementBody (this=0x7fffffffba70, Decl=0xe72f50) at /home/sojka/boost-statechart-viewer/clang/lib/Parse/ParseStmt.cpp:1479
#17 0x000000000043633c in clang::Parser::ParseFunctionDefinition (this=0x7fffffffba70, D=..., TemplateInfo=...)
     at /home/sojka/boost-statechart-viewer/clang/lib/Parse/Parser.cpp:720
#18 0x000000000043c38c in clang::Parser::ParseDeclGroup (this=0x7fffffffba70, DS=..., Context=0, AllowFunctionDefinitions=true, DeclEnd=0x0)
     at /home/sojka/boost-statechart-viewer/clang/lib/Parse/ParseDecl.cpp:438
#19 0x0000000000435eb1 in clang::Parser::ParseDeclarationOrFunctionDefinition (this=0x7fffffffba70, DS=..., Attr=0x0, AS=clang::AS_none)
     at /home/sojka/boost-statechart-viewer/clang/lib/Parse/Parser.cpp:621
#20 0x0000000000435f1d in clang::Parser::ParseDeclarationOrFunctionDefinition (this=0x7fffffffba70, Attr=0x0, AS=clang::AS_none)
     at /home/sojka/boost-statechart-viewer/clang/lib/Parse/Parser.cpp:628
#21 0x00000000004358a5 in clang::Parser::ParseExternalDeclaration (this=0x7fffffffba70, Attr=..., DS=0x0) at /home/sojka/boost-statechart-viewer/clang/lib/Parse/Parser.cpp:512
#22 0x0000000000448398 in clang::Parser::ParseNamespace (this=0x7fffffffba70, Context=0, DeclEnd=..., InlineLoc=...)
     at /home/sojka/boost-statechart-viewer/clang/lib/Parse/ParseDeclCXX.cpp:124
#23 0x000000000043beb2 in clang::Parser::ParseDeclaration (this=0x7fffffffba70, Context=0, DeclEnd=..., Attr=...)
     at /home/sojka/boost-statechart-viewer/clang/lib/Parse/ParseDecl.cpp:352
#24 0x00000000004356f1 in clang::Parser::ParseExternalDeclaration (this=0x7fffffffba70, Attr=..., DS=0x0) at /home/sojka/boost-statechart-viewer/clang/lib/Parse/Parser.cpp:483
#25 0x0000000000435193 in clang::Parser::ParseTopLevelDecl (this=0x7fffffffba70, Result=...) at /home/sojka/boost-statechart-viewer/clang/lib/Parse/Parser.cpp:370
#26 0x000000000041e1c4 in clang::ParseAST (S=..., PrintStats=false) at /home/sojka/boost-statechart-viewer/clang/lib/Parse/ParseAST.cpp:83
#27 0x000000000041e063 in clang::ParseAST (PP=..., Consumer=0x7fffffffe360, Ctx=..., PrintStats=false, CompleteTranslationUnit=true, CompletionConsumer=0x0)
     at /home/sojka/boost-statechart-viewer/clang/lib/Parse/ParseAST.cpp:61
#28 0x00000000004134de in main (argc=4, argv=0x7fffffffe638) at visualizer.cpp:463


You can download the source files and test files at:

http://rtime.felk.cvut.cz/gitweb/boost-statechart-viewer.git

Can you help me with solving this error. My opinion is that there could 
be an error in defining language options.

Thank you for your reply.

Best regards

Petr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110325/ab2ee2d6/attachment.html>


More information about the cfe-dev mailing list