[cfe-dev] [Bug] Segmentation fault while getting SourceLocation of a Decl

Jordan Rose jordan_rose at apple.com
Fri Mar 14 09:44:48 PDT 2014


That sounds like you're ending up with null FunctionDecl pointers—notice the "this=0x21" in your backtrace. Are you modifying the map while you're iterating over it? That's always dangerous.

Jordan


On Mar 14, 2014, at 8:10 , Hugues de Lassus <hugues.de-lassus at imag.fr> wrote:

> Hi,
> 
> I am iterating on an std::map whose keys are FunctionDecl's pointers. Many times I encounter no problems, but sometimes I get segfaults for specific C files and I do not manage to find out why nor where parsed C code might produces such a bug.
> 
> Every time it happens when calling clang::FunctionDecl::getNameInfo() and then clang::Decl::getLocation()
> 
> I am wondering whether the getNameInfo/getLocation functions are always safe or not ? Do you think it has to come from my tool ? Thanks for the help !
> 
> Here is an example backtrace:
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x0000000000544bb6 in clang::Decl::getLocation (this=0x21) at /import/linux/x86_64/soft/llvm/3.4/include/clang/AST/DeclBase.h:373
> 373      SourceLocation getLocation() const { return Loc; }
> (gdb) bt
> #0  0x0000000000544bb6 in clang::Decl::getLocation (this=0x21) at /import/linux/x86_64/soft/llvm/3.4/include/clang/AST/DeclBase.h:373
> #1  0x0000000000544c14 in clang::FunctionDecl::getNameInfo (this=0x21) at /import/linux/x86_64/soft/llvm/3.4/include/clang/AST/Decl.h:1605
> #2  0x000000000054454f in DotGraph::printDotGraph (this=0x7fffffffe260, IOInfo=0x14eb110) at DotGraph.cpp:32
> #3  0x000000000058e27d in main (argc=4, argv=0x7fffffffe658) at main.cpp:73
> 
> -- 
> 
> Hugues de Lassus Saint-Geniès
> 
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev





More information about the cfe-dev mailing list