sarojvarma / include-what-you-use

Automatically exported from code.google.com/p/include-what-you-use
Other
0 stars 0 forks source link

Crash #57

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Not sure what caused this particular crash, but it was happening a lot in my 
source files.  The attached patch fixes it.

Original issue reported on code.google.com by ryan.pav...@gmail.com on 4 Aug 2011 at 8:26

Attachments:

GoogleCodeExporter commented 9 years ago
Hmm, I'd like to understand this a bit better: I'm concerned if we're seeing 
uses that aren't at valid locations.  Do you mind running through the debugger 
(running iwyu with --v=6 should show a workable gdb command) or similar, and 
seeing what constructs are getting here with an invalid source-location?  Are 
they actually correct uses?

Original comment by csilv...@gmail.com on 9 Aug 2011 at 12:46

GoogleCodeExporter commented 9 years ago
Ping.  Any more word on this?

Original comment by csilv...@gmail.com on 25 Oct 2011 at 1:41

GoogleCodeExporter commented 9 years ago
I think I'm hitting this as well with latest llvm, clang, and iwuy trunk.

 "/opt/llvm/bin/include-what-you-use" "-cc1" "-triple" "x86_64-apple-macosx10.7.2" "-fsyntax-only" "-disable-free" "-main-file-name" "mapnik_expression.cpp" "-pic-level" "2" "-mdisable-fp-elim" "-masm-verbose" "-munwind-tables" "-target-cpu" "core2" "-target-linker-version" "127.2" "-v" "-resource-dir" "/opt/llvm/bin/../lib/clang/3.1" "-D" "HAVE_JPEG" "-D" "DARWIN" "-D" "BOOST_SPIRIT_THREADSAFE" "-D" "MAPNIK_THREADSAFE" "-D" "NDEBUG" "-D" "HAVE_CAIRO" "-I" "deps/agg/include" "-I" "." "-I" "include" "-I" "/usr/local/Cellar/postgresql/9.0.4/include" "-I" "/usr/local/Cellar/icu4c/4.8.1/include" "-I" "/usr/local/include" "-I" "/usr/include" "-I" "/usr/X11/include/freetype2" "-I" "/usr/X11/include" "-I" "/usr/include/libxml2" "-I" "/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7" "-I" "/usr/local/Cellar/cairomm/1.8.4/include/cairomm-1.0" "-I" "/usr/local/Cellar/cairomm/1.8.4/lib/cairomm-1.0/include" "-I" "/usr/local/Cellar/libsigc++/2.2.9/include/sigc++-2.0" "-I" "/usr/local/Cellar/libsigc++/2.2.9/lib/sigc++-2.0/include" "-I" "/usr/X11/include/cairo" "-I" "/usr/X11/include/pixman-1" "-I" "/usr/X11/include/libpng15" "-fmodule-cache-path" "/var/folders/dw/3_t671bx2cx9f23ywm4300080000gn/T/clang-module-cache" "-O3" "-Wall" "-Wno-inline" "-Wno-parentheses" "-Wno-char-subscripts" "-std=c++98" "-fdeprecated-macro" "-fdebug-compilation-dir" "/Users/dane/projects/mapnik" "-ftemplate-depth" "300" "-ferror-limit" "19" "-fmessage-length" "174" "-stack-protector" "1" "-fblocks" "-fobjc-runtime-has-arc" "-fobjc-runtime-has-weak" "-fobjc-dispatch-method=mixed" "-fcxx-exceptions" "-fexceptions" "-fdiagnostics-show-option" "-fcolor-diagnostics" "-x" "c++" "bindings/python/mapnik_expression.cpp"

clang -cc1 version 3.1 based upon llvm 3.1svn default target 
x86_64-apple-darwin11.2.0
ignoring nonexistent directory 
"/usr/include/c++/4.2.1/i686-apple-darwin10/x86_64"
ignoring nonexistent directory "/usr/include/c++/4.0.0"
ignoring nonexistent directory "/usr/include/c++/4.0.0/i686-apple-darwin8/"
ignoring nonexistent directory "/usr/include/c++/4.0.0/backward"
ignoring duplicate directory "/usr/local/include"
  as it is a non-system directory that duplicates a system directory
ignoring duplicate directory "/usr/include"
  as it is a non-system directory that duplicates a system directory
#include "..." search starts here:
#include <...> search starts here:
 deps/agg/include
 .
 include
 /usr/local/Cellar/postgresql/9.0.4/include
 /usr/local/Cellar/icu4c/4.8.1/include
 /usr/X11/include/freetype2
 /usr/X11/include
 /usr/include/libxml2
 /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7
 /usr/local/Cellar/cairomm/1.8.4/include/cairomm-1.0
 /usr/local/Cellar/cairomm/1.8.4/lib/cairomm-1.0/include
 /usr/local/Cellar/libsigc++/2.2.9/include/sigc++-2.0
 /usr/local/Cellar/libsigc++/2.2.9/lib/sigc++-2.0/include
 /usr/X11/include/cairo
 /usr/X11/include/pixman-1
 /usr/X11/include/libpng15
 /usr/include/c++/4.2.1
 /usr/include/c++/4.2.1/backward
 /usr/local/include
 /opt/llvm/bin/../lib/clang/3.1/include
 /usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.
Stack dump:
0.  <eof> parser at end of file
Segmentation fault: 11

Original comment by d...@dbsgeo.com on 6 Nov 2011 at 5:59

GoogleCodeExporter commented 9 years ago
backtrace in gdb looks like:

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000
0x0000000100595f70 in clang::Stmt::getSourceRange ()
(gdb) bt
#0  0x0000000100595f70 in clang::Stmt::getSourceRange ()
#1  0x00000001005b0416 in clang::TemplateArgumentLoc::getSourceRange ()
#2  0x000000010008d47f in include_what_you_use::GetLocation ()
#3  0x0000000100069d51 in include_what_you_use::ASTNode::FillLocationIfKnown ()
#4  0x0000000100069bf5 in include_what_you_use::ASTNode::GetLocation ()
#5  0x00000001000048a6 in 
include_what_you_use::BaseAstVisitor<include_what_you_use::IwyuAstConsumer>::Cur
rentLoc ()
#6  0x00000001000027f9 in non-virtual thunk to 
include_what_you_use::IwyuAstConsumer::ShouldPrintSymbolFromCurrentFile() const 
()
#7  0x0000000100064b9f in 
include_what_you_use::BaseAstVisitor<include_what_you_use::IwyuAstConsumer>::Vis
itTemplateArgumentLoc ()
#8  0x00000001000209d7 in 
include_what_you_use::BaseAstVisitor<include_what_you_use::IwyuAstConsumer>::Tra
verseTemplateArgumentLoc ()
#9  0x000000010001fe1a in 
clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseTempl
ateSpecializationTypeLoc ()
#10 0x000000010001e963 in 
clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseTypeL
oc ()
#11 0x000000010001e62c in 
include_what_you_use::BaseAstVisitor<include_what_you_use::IwyuAstConsumer>::Tra
verseTypeLoc ()
#12 0x0000000100068754 in 
clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseConst
ructorInitializer ()
#13 0x000000010006860b in 
clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseFunct
ionHelper ()
#14 0x000000010000a818 in 
include_what_you_use::BaseAstVisitor<include_what_you_use::IwyuAstConsumer>::Tra
verseCXXConstructorDecl ()
#15 0x0000000100006f05 in 
clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseDecl 
()
#16 0x0000000100009b88 in 
clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseClass
TemplateSpecializationDecl ()
#17 0x0000000100006e41 in 
clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseDecl 
()
#18 0x0000000100007f28 in 
clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseNames
paceDecl ()
#19 0x0000000100006d20 in 
clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseDecl 
()
#20 0x0000000100007f28 in 
clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseNames
paceDecl ()
#21 0x0000000100006d20 in 
clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseDecl 
()
#22 0x0000000100007f28 in 
clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseNames
paceDecl ()
#23 0x0000000100006d20 in 
clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseDecl 
()
#24 0x000000010000b838 in 
clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseDeclC
ontextHelper ()
#25 0x0000000100006ff2 in 
clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseDecl 
()
#26 0x00000001000023f0 in 
include_what_you_use::IwyuAstConsumer::HandleTranslationUnit ()
#27 0x00000001001e5ece in clang::ParseAST ()
#28 0x00000001000c1cfb in clang::CompilerInstance::ExecuteAction ()
#29 0x000000010000148b in main ()
(gdb) Quit

Original comment by d...@dbsgeo.com on 6 Nov 2011 at 6:00

GoogleCodeExporter commented 9 years ago
I found I had to comment the line `return argloc->getLocation()` on line 162 of 
iwyu_location_util.c to avoid this segfault, for reasons I could not see.

Original comment by d...@dbsgeo.com on 6 Nov 2011 at 6:43

GoogleCodeExporter commented 9 years ago
dane -- I think this is probably a bug in clang, where the sourceloc isn't 
getting filled in in a case it should be.  But hard to be sure.  If you can, 
feel free to poke around in gdb a bit to see what's NULL, and if it seems like 
it ought to be.

Original comment by csilv...@gmail.com on 6 Nov 2011 at 7:37

GoogleCodeExporter commented 9 years ago
I am currently experiencing this issue as well (with the libreoffice code 
base), is there a way that I can provide any more information?

Original comment by augsod@gmail.com on 22 Nov 2011 at 6:15

GoogleCodeExporter commented 9 years ago
augsod: you could run in gdb and see if you can figure out where the bug is.  
Ideally you'd find a small test-case that would reproduce this just in clang 
(without requiring iwyu) and submit it to the clang folks.  But that would 
probably require some clang knowledge.

Original comment by csilv...@gmail.com on 22 Nov 2011 at 4:16

GoogleCodeExporter commented 9 years ago
I just ran into this problem, and spent a while debugging it. I don't know what 
the exact cause is, but here's an extremely simple test case that demonstrates 
the issue.

Tested with Clang 3.1, and IWYU r371 with the addCommentHandler change reverted 
so that it compiles against 3.1.

Run with the following command line:
./iwyu -std=gnu++0x bad.cpp

Here's the contents of bad.cpp:

template<typename T>
class Foo {
};

template<typename T>
void g(Foo<T> x) {
  auto y = x;
}

int main() {
  return 0;
}

Original comment by christop...@gmail.com on 5 Nov 2012 at 10:30

GoogleCodeExporter commented 9 years ago
Thanks for test case, Christopher. I am able to reproduce the crash with it. 
But it looks more like issue #79 where we have problem with "auto" too.

Original comment by vsap...@gmail.com on 6 Nov 2012 at 8:27

GoogleCodeExporter commented 9 years ago
FWIW, I didn't have "auto" used in the code that generated these crashes.
(my fork of luabind on github, IIRC)

Original comment by ryan.pav...@gmail.com on 12 Dec 2012 at 7:50

GoogleCodeExporter commented 9 years ago
Hmm, it's dangerous to have an issue called "Crash", it tends to attract 
unrelated problems :-)

Could you give luabind a try again, and see if you can reproduce this problem 
with a callstack or something to narrow it down?

Original comment by kim.gras...@gmail.com on 12 Dec 2012 at 9:25

GoogleCodeExporter commented 9 years ago
A very simple testcase:

#include <iostream>

int main(int argc, char** argv) {
        return 0;
}

It only crashes if '-std=c++11' is used on the command line. Omitting the 
include also doesn't lead to the crash. This is tested using clang 3.2 and the 
appropriate (up-to-date) branch of iwyu.

The backtrace:

Program terminated with signal 11, Segmentation fault.
#0  0x0000000000592e8a in 
include_what_you_use::BaseAstVisitor<include_what_you_use::IwyuAstConsumer>::Tra
verseType(clang::QualType) ()
(gdb) bt
#0  0x0000000000592e8a in 
include_what_you_use::BaseAstVisitor<include_what_you_use::IwyuAstConsumer>::Tra
verseType(clang::QualType) ()
#1  0x00000000005939fc in 
clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseAutoT
ypeLoc(clang::AutoTypeLoc) ()
#2  0x0000000000595042 in 
include_what_you_use::BaseAstVisitor<include_what_you_use::IwyuAstConsumer>::Tra
verseTypeLoc(clang::TypeLoc) ()
#3  0x0000000000599697 in 
clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseDecla
ratorHelper(clang::DeclaratorDecl*) ()
#4  0x00000000005998b1 in 
clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseVarHe
lper(clang::VarDecl*) ()
#5  0x0000000000599953 in 
clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseVarDe
cl(clang::VarDecl*) ()
#6  0x000000000054df0d in 
include_what_you_use::BaseAstVisitor<include_what_you_use::IwyuAstConsumer>::Tra
verseDecl(clang::Decl*) [clone .part.2833] ()
#7  0x00000000005942c0 in 
clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseDeclS
tmt(clang::DeclStmt*) ()
#8  0x000000000054d99d in 
include_what_you_use::BaseAstVisitor<include_what_you_use::IwyuAstConsumer>::Tra
verseStmt(clang::Stmt*) [clone .part.2821] ()
#9  0x000000000058c988 in 
clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseCompo
undStmt(clang::CompoundStmt*) ()
#10 0x000000000054d99d in 
include_what_you_use::BaseAstVisitor<include_what_you_use::IwyuAstConsumer>::Tra
verseStmt(clang::Stmt*) [clone .part.2821] ()
#11 0x000000000054df0d in 
include_what_you_use::BaseAstVisitor<include_what_you_use::IwyuAstConsumer>::Tra
verseDecl(clang::Decl*) [clone .part.2833] ()
#12 0x0000000000594a47 in 
clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseFunct
ionTemplateDecl(clang::FunctionTemplateDecl*) ()
#13 0x000000000054df0d in 
include_what_you_use::BaseAstVisitor<include_what_you_use::IwyuAstConsumer>::Tra
verseDecl(clang::Decl*) [clone .part.2833] ()
#14 0x0000000000594363 in 
clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseDeclC
ontextHelper(clang::DeclContext*) ()
#15 0x000000000054df0d in 
include_what_you_use::BaseAstVisitor<include_what_you_use::IwyuAstConsumer>::Tra
verseDecl(clang::Decl*) [clone .part.2833] ()
#16 0x0000000000594363 in 
clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseDeclC
ontextHelper(clang::DeclContext*) ()
#17 0x000000000054df0d in 
include_what_you_use::BaseAstVisitor<include_what_you_use::IwyuAstConsumer>::Tra
verseDecl(clang::Decl*) [clone .part.2833] ()
#18 0x0000000000593eeb in 
include_what_you_use::IwyuAstConsumer::HandleTranslationUnit(clang::ASTContext&)
 ()
#19 0x000000000074bd12 in clang::ParseAST(clang::Sema&, bool, bool) ()
#20 0x00000000005fe221 in clang::FrontendAction::Execute() ()
#21 0x00000000005e1d95 in 
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) ()
#22 0x000000000054ab46 in main ()

Original comment by andre.st...@gmail.com on 19 Mar 2013 at 11:57

GoogleCodeExporter commented 9 years ago
This is already fixed in: 
https://code.google.com/p/include-what-you-use/source/detail?r=421.

The Clang 3.2 branch was taken at r385, so this didn't make it in.

Let me know if this is critical for you and I can try and merge r421 over to 
the 3.2 branch.

Original comment by kim.gras...@gmail.com on 19 Mar 2013 at 12:30

GoogleCodeExporter commented 9 years ago
I'd like to close this issue, as it seems to attract all kinds of unrelated 
reports. Any objections?

Original comment by kim.gras...@gmail.com on 6 Jun 2014 at 1:05

GoogleCodeExporter commented 9 years ago
No objections.

Original comment by vsap...@gmail.com on 6 Jun 2014 at 4:51

GoogleCodeExporter commented 9 years ago
This issue seems to attract all crashes in the world. Closing it in the hope 
that new issues may come for new crashes.

Original comment by kim.gras...@gmail.com on 6 Jun 2014 at 8:25