[cfe-dev] TraverseDecl generate Segmentation fault

Richard Smith richard at metafoo.co.uk
Mon May 9 10:24:04 PDT 2011


Hi!

On Sun, 8 May 2011 12:57, Hao Jiang wrote:
> I wrote a plugin to use clang traversing AST. It used to work fine but
> after I updated and built clang today It generated  exception as
> following:
> 0  clang           0x000000000247b4bd 1  clang           0x000000000247b2b0
>  2  libpthread.so.0 0x00007f352be90190
> 3  libAnnotate.so  0x00007f352af51c08
> clang::RecursiveASTVisitor<minissf::Annotate>::TraverseTypeAliasDecl(clang
> ::TypeAliasDecl*)
> + 24
> 4  libAnnotate.so  0x00007f352af4e201
> clang::RecursiveASTVisitor<minissf::Annotate>::TraverseDeclContextHelper(c
> lang::DeclContext*)
> + 65
> 5  libAnnotate.so  0x00007f352af4e835
> clang::RecursiveASTVisitor<minissf::Annotate>::TraverseStaticAssertDecl(cl
> ang::StaticAssertDecl*)
> + 85
> 6  clang           0x00000000012bf31a clang::ParseAST(clang::Sema&, bool)
> +
> 667
> 7  clang           0x000000000101bad3
> clang::ASTFrontendAction::ExecuteAction() + 263
> 8  clang           0x000000000101b724 clang::FrontendAction::Execute() +
> 326
> 9  clang           0x0000000001002ae5
> clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 751
> 10 clang           0x0000000000faa14f
> clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 908
> 11 clang           0x0000000000f9bde7 cc1_main(char const**, char const**,
>  char const*, void*) + 982 12 clang           0x0000000000fa589d main +
> 499
> 13 libc.so.6       0x00007f352b180abd __libc_start_main + 253
> 14 clang           0x0000000000f9b489
> Stack dump:
> 0.	Program arguments: clang -cc1 -I../.. -load
> ../../../xlate/Annotate/libAnnotate.so -plugin minissf-annotate chevt.cc
> 1.	<eof> parser at end of file
> Segmentation fault
> I also tried to run BoostConAction example, it generate same error. It
> seems to me that TraverseDecl function does not work after updating.
> Anyone knows
> how to fix it? Thank you very much for your help. Hao Jiang

C++0x alias declarations are a very new feature in clang, so it's possible
that there are major bugs with them. However, I was not able to reproduce
this failure by running 'clang++ -cc1 -std=c++0x -boostcon
some-file-with-aliases.cpp', and I note that you do not have -std=c++0x in
your compilation command line. Therefore I suspect that your code does not
in fact contain a TypeAliasDecl, and certainly not one contained within a
StaticAssertDecl.

Is it possible that you have not rebuilt some parts of clang or llvm (or
maybe your plugin) after your most recent svn update? Does a clean build
help? If not, can you provide instructions to reproduce this issue? A
preprocessed source file and a compilation command line using
BoostConAction would be ideal.

Thanks,
Richard





More information about the cfe-dev mailing list